You are here:  » Random categories

Support Forum



Random categories

Submitted by paullas on Mon, 2007-11-12 09:44 in

hi

not sure if this is possible but ill give it a go.

if you look at http://www.simplygadgets.co.uk/ see where i have put categories on the left. well is it possible for the script to randomly display say 10 categories there instead of me inserting them.

thanks in advance

paul

Submitted by support on Mon, 2007-11-12 09:56

Hi Paul,

Try the following code to select 10 random categories:

<?php
  $sql 
"SELECT DISTINCT(category) AS category FROM `".$config_databaseTablePrefix."products` LIMIT 10";
  if (
database_querySelect($sql,$rows))
  {
    foreach(
$rows as $row)
    {
      
$href "search.php?q=category:".urlencode($row["category"]);
      print 
"<a href='".$href."'>".$row["category"]."</a><br />";
    }
  }
?>

If you are already in PHP mode, don't include the PHP tags of course...

Cheers,
David.

Submitted by paullas on Mon, 2007-11-12 10:02

ok added the above http://www.simplygadgets.co.uk/ but they dont seem to be randomly changing ? any ideas

thanks

paul

Submitted by support on Mon, 2007-11-12 10:09

Hi Paul,

Sorry about that - I missed the RAND() ordering off the SQL! Instead of:

$sql = "SELECT DISTINCT(category) AS category FROM `".$config_databaseTablePrefix."products` LIMIT 10";

Try:

$sql = "SELECT DISTINCT(category) AS category FROM `".$config_databaseTablePrefix."products` ORDER BY RAND() LIMIT 10";

Keep an eye on the performance when doing queries that are used every time your home page is viewed. If the page is (or becomes) slow to load then another method will need to be used to do this...

Cheers,
David.

Submitted by paullas on Mon, 2007-11-12 10:17

thanks ill keep an eye on that over coming days.

ok another question if thats ok.

you see the front page, the search box and under that it says Search or browse by merchant, category or brand. How would i move them so they are under the 3 products i have rather above them.

thanks again, much appreciated

paul

Submitted by support on Mon, 2007-11-12 10:59

Hi Paul,

To move the links, simply cut the section of code between (and including) the lines that print the P tags to enclose the links (they're next the the lines that print the SMALL tags as described above), and then paste it all back in below the following the line near the bottom of the script:

  if (isset($featured)) require("html/featured.php");

Cheers,
David.

Submitted by paullas on Mon, 2007-11-12 11:53

thank you david for all your help
what do you think so far http://www.simplygadgets.co.uk/

keep up the great work

paul

p.s

how do i know my affiliate id is being tracked from my new site?

Submitted by support on Mon, 2007-11-12 11:58

Hi Paul,

Looks good!

Regarding the affiliate tracking, if you end up at a merchants site when you click a link, then you can be pretty sure that everything is working as you must have gone via the affiliate networks' servers, most networks don't forward the click if there is a problem with the link.

Cheers,
David.

Submitted by paullas on Mon, 2007-11-12 12:10

hi

i have been told my site is going direct to site and now using my affiliate link. is there anyway i can verify this

thanks

paul

Submitted by support on Mon, 2007-11-12 12:21

Hi Paul,

You can always check the URLs you are going to by turning off tracking. In config.php, set:

$config_useTracking = false;

Then, hover your mouse over a link from your site and check that the URL is your affiliate URL. I've just followed the redirects from your site to firebox.com and it looks fine - the first hop is your affiliate URL.

Cheers,
David.