You are here:  » List of merchant for sidebar

Support Forum



List of merchant for sidebar

Submitted by Patate on Sun, 2007-02-18 20:16 in

Hi,

I try to list the merchants' name (for my homepage sidebar). Does anyone find the function ?

Thanks in advance !

Submitted by support on Mon, 2007-02-19 06:07

Hi,

There isn't a function to do this but it should be straight forward. The PHP code would be something like this:

<?php
  
print "<p>Merchant List</p>";
  print 
"<ul>";
  
$sql "SELECT * FROM `".$config_databaseTablePrefix."feeds` ORDER BY merchant";
  if (
database_querySelect($sql,$rows))
  {
    foreach(
$rows as $feed)
    {
      if (
$config_useRewrite)
      {
        
$href "merchant/".tapestry_hyphenate($feed["merchant"])."/";
      }
      else
      {
        
$href "search.php?q=merchant:".urlencode($feed["merchant"]).":";
      }
      print 
"<li><a href='".$href."'>".$feed["merchant"]."</a></li>";
    }
  }
  print 
"</ul>";
?>

Hope this helps!
Cheers,
David.

Submitted by Patate on Mon, 2007-02-19 14:17

Terrific ! Thanks a lot !

Just a strange error with the rewrited urls.
homepage : http://www.domain.com/ + merchant name
product : http://www.domain.com/product/ + merchant name
etc...

Submitted by support on Mon, 2007-02-19 14:30

Oops - I missed out the "merchant/" in front of the merchant name in the rewrite case of the above code. I've fixed it now (in the code above)...

Cheers,
David.

Submitted by Patate on Mon, 2007-02-19 17:55

argh ! not yet ! ;-)

Product page :
http://www.domain.tld/product/merchant/ + merchant name...

Thank you.

Submitted by support on Mon, 2007-02-19 17:57

Ah, sorry - I thought this menu was going on your home page.

In that case, all you need to do is prefix the URL with $config_baseHREF, like this:

<?php
  
print "<p>Merchant List</p>";
  print 
"<ul>";
  
$sql "SELECT * FROM `".$config_databaseTablePrefix."feeds` ORDER BY merchant";
  if (
database_querySelect($sql,$rows))
  {
    foreach(
$rows as $feed)
    {
      if (
$config_useRewrite)
      {
        
$href $config_baseHREF."merchant/".tapestry_hyphenate($feed["merchant"])."/";
      }
      else
      {
        
$href $config_baseHREF."search.php?q=merchant:".urlencode($feed["merchant"]).":";
      }
      print 
"<li><a href='".$href."'>".$feed["merchant"]."</a></li>";
    }
  }
  print 
"</ul>";
?>

Should work fine then!
Cheers,
David.

Submitted by Patate on Mon, 2007-02-19 19:13

Perfect !
Thanks again.

Patate

Submitted by cataleptic on Mon, 2007-02-19 19:44

How can you list only say 5 of the top retailers?

Submitted by support on Mon, 2007-02-19 19:46

Hi,

The trouble with that is that there is no metric within the system by which you can determine "top". You could of course limit the list to a random selection of 5 retailers...

  $sql = "SELECT * FROM `".$config_databaseTablePrefix."feeds` ORDER BY RAND() LIMIT 5";

Cheers,
David.