You are here:  » navigation on all pages


navigation on all pages

Submitted by support on Sat, 2006-07-15 17:19 in

[originally posted by badger but accidentally deleted - sorry :o]

Hiya, how would you go about having the merchant, category or brand lists in an A or C column?

You could have the categories list as default, but if you click on merchant or brand the list reloads and your current search results remain unchanged.

It seems more complicated than i though it would be.

Thanks

Submitted by support on Sat, 2006-07-15 17:40

To populate the A to Z lists within search.php you first need to have a case statement deciding which list to display; defaulting as you suggest to the category list:

<?php
  
if ($_GET["atoz"] == "merchant")
  {
    
// copy code from merchants.php here
  
}
  elseif (
$_GET["atoz"] == "brand")
  {
    
// copy code from brands.php here
  
}
  else
  {
    
// copy code from categories.php here
  
}
?>

Put the above section of code immediately before the following mods at the bottom of search.php just before the display modules are called.

Where is says "copy code from....", you want the main body of code from each of those scripts that performs the SQL query and then populates the $atoz array. In each case, it starts on the line after the single require() statement at the top; until the line containing $banner["h2"]...

Now, to make it so that you can swap to a different list with the search results staying the same you have construct a URL to the new page (with atoz=whatever) but persisting all the existing search parameters - "query", "page" and "sort". The code would look something like this:

<?php
  $atozHREF 
$config_baseHREF."search.php?q=".urlencode($q)."&amp;page=".$page."&amp;sort=".$sort."&atoz=";
  print 
"<p><a href='".$atozHREF."merchant'>Merchant A-Z</a></p>";
  print 
"<p><a href='".$atozHREF."category'>Category A-Z</a></p>";
  print 
"<p><a href='".$atozHREF."brand'>Brand A-Z</a></p>";
?>

For display, you can then reuse the existing atoz.php HTML module. So to put the list in column A (using a table) and to combine the links to the different lists, do something like this at the bottom of search.php:

<?php
  
require("html/header.php");
  require(
"html/menu.php");
  require(
"html/searchform.php");
  require(
"html/banner.php");
  print 
"<table>";
  print 
"<tr>";
  print 
"<td>";
  require(
"html/atoz.php");  
  
$atozHREF $config_baseHREF."search.php?q=".urlencode($q)."&amp;page=".$page."&amp;sort=".$sort."&atoz=";
  print 
"<p><a href='".$atozHREF."merchants'>Merchant A-Z</a></p>";
  print 
"<p><a href='".$atozHREF."categories'>Category A-Z</a></p>";
  print 
"<p><a href='".$atozHREF."brands'>Brand A-Z</a></p>";
  print 
"</td>";
  print 
"<td>";
  if (isset(
$searchresults))
  {
    if (
$searchresults["numRows"])
    {
      require(
"html/searchresults.php");
    }
    else
    {
      require(
"html/noresults.php");
    }
  }
  if (isset(
$navigation)) require("html/navigation.php");
  print 
"</td>";
  print 
"</tr>";
  print 
"</table>";
  require(
"html/footer.php");
?>

Should give you something to work from!

Cheers,
David.

Submitted by badger on Sat, 2006-07-15 19:53

Thats fantastic David, thanks.

The nav defaults to category alright. However if you click on any of the list items the new search results page also defaults to category. hence changing the list the user opened.

Is there a way to only use the default of category if the user didnt make a selection yet, otherwise keeping it the same?

thanks again

Submitted by support on Sat, 2006-07-15 20:30

If you look for the following line in html/atoz.php...

    print "<p><a href='".$item["href"]."'>".$item["name"]."</a></p>";

and change it to...

    print "<p><a href='".$item["href"]."&atoz=".$_GET["atoz"]."'>".$item["name"]."</a></p>";

That should do the trick.

Cheers,
David.

Submitted by support on Sat, 2006-07-15 20:47

Adds....

As well as making the above change, you will also need to remove the test for $config_useRewrite in each of the sections of code that generate the atoz values (merchant, category and brand) in your new search.php.

Currently, you have something like this for each one:

        if ($config_useRewrite)
        {
          $item["href"] = tapestry_hyphenate($product["brand"])."/";
        }
        else
        {
          $item["href"] = "search.php?q=brand:".urlencode($product["brand"]).":";
        }

Change each of those to just:

        $item["href"] = "search.php?q=brand:".urlencode($product["brand"]).":";

This is because the rewrite versions won't work with a value appended to the URL because they do not have a query string already...!

Submitted by badger on Sun, 2006-07-16 10:07

thanks David,

is that a massive job to fix the URL rewriting?

at the moment the rewritten URL is http://localhost/kb_test/Apple/&atoz=brand

it would be nicer like this
http://localhost/kb_test/brand/Apple/

and the actual URL is
http://localhost/kb_test/search.php?q=brand:Apple:&atoz=brand

Would it involve more than just editing .htaccess and atoz.php?

btw, is there a version of pt with comments? im oviously not a developer but could be a lot more effective if i had a better understanding of the code.

cheers

Submitted by badger on Sun, 2006-07-16 10:45

Thanks for your help so far David.