You are here:  » Help with Template

Support Forum



Help with Template

Submitted by dalster on Wed, 2007-03-21 22:04 in

Hi,

I've started playing with a css template.

How do I get the info where I want though?
As you can see at www.dalster.com the search over laps in the left column.

If I wanted search at top of right column, followed by Categories, what would I need to do?

Right column will just be Adsense so thats easy.

The in the center I would want "Featured Products"

Thanks for any help.

Submitted by support on Thu, 2007-03-22 08:45

Hi,

I would suggest using a table layout to create 3 columns with search / categories left, featured center, AdSense on the right. You can do this by making changes in:

- html/header.php
- html/footer.php

At the end of html/header.php do something like this:

<table width='100%'>
<tr>
<td width='150' valign='top'>
*** YOUR LEFT COLUMN CONTENT GOES HERE
</td>
<td valign='top'>

And then at the top of html/footer.php add this:

</td>
<td width='150' valign='top'>
*** YOUR RIGHT COLUMN CONTENT / ADSENSE GOES HERE
</td>
</tr>
</table>

That should create the basic layout. Now, you've mentioned that you want to have a search box and categories on the left. The first thing to do is include the search box HTML module within the above code. So, where you have *** YOUR LEFT COLUMN CONTENT GOES HERE *** add the following:

<?php
  
require("html/searchform.php");
?>

Having done that, you might want to edit html/searchform.php to change the size of the textbox as it will probably be too long for your left hand column.

Finally, to display a list of category (although I don't really recommend doing this because of the performance aspects and the fact that the list could be really long!) use the following code - again in your left hand column area:

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

As an alternative, I would recommend instead create hard coded links to your categories by linking directly to the search page for the category you want to link to, for example:

<a href='/search.php?q=category:Electronics'>Electronics</a>

There's quite a lot to take in here, so I would recommend taking it one step at a time with the column mods first - then test it with some fixed HTML in each column to get it working how you want. Then try adding the search box, and finally the category list if that is what you want to do...

Hope this helps,
Cheers,
David.

Submitted by dalster on Thu, 2007-03-22 08:49

Thanks, it does help. one thing I'm not understanding.

The index.php file, does that have to be touched?

So, if I add a search function like suggested above, do I eliminate it from index.php.

This is what is unfortunately confusing me quite a bit, I'm not sure what to edit and what you don't touch.

Submitted by support on Thu, 2007-03-22 10:01

Hi,

Yes - you can remove it from index.php if you wish - no problem. The line that brings in the search form is:

require("html/searchform.php");

...but you might also want to remove the other code from around that section that displays the links to browse by merchant, category or brand - or perhaps even move this code into your left hand column...

To make it clearer if it will help, the following is the code you don't need in index.php:

  require("html/searchform.php");
  print "<p>";
  print "<small>";
  print translate("Search or browse by")." ";
  print "<a href='".($config_useRewrite?"merchant/":"merchants.php")."'>".translate("merchant")."</a>, ";
  print "<a href='".($config_useRewrite?"category/":"categories.php")."'>".translate("category")."</a> ".translate("or")." ";
  print "<a href='".($config_useRewrite?"brand/":"brands.php")."'>".translate("brand")."</a>";
  print "</small>";
  print "</p>";

Of the above code, if you want to display the links to the merchant, category and brand index pages the code you need to move into your left hand column is the following:

<?php
  
print "<p>";
  print 
"<small>";
  print 
translate("Search or browse by")." ";
  print 
"<a href='".($config_useRewrite?"merchant/":"merchants.php")."'>".translate("merchant")."</a>, ";
  print 
"<a href='".($config_useRewrite?"category/":"categories.php")."'>".translate("category")."</a> ".translate("or")." ";
  print 
"<a href='".($config_useRewrite?"brand/":"brands.php")."'>".translate("brand")."</a>";
  print 
"</small>";
  print 
"</p>";
?>

Finally, if you have removed the search form from index.php you should also remove the following line:

print javascript_focus("search.q");

Hope this helps!
Cheers,
David.