Support forum login

©2006-2012 IAAI Software

Contact Us Privacy Policy

Category and Brand infopages

Submitted by esogut on Thu, 2010-01-21 22:03.

Hi David,

I like to add information text for the categories and brands. we have over 80 categories so it wasnt a option for me to hardcode the text do you have a nice solution for this
thnx

Submitted by support on Fri, 2010-01-22 09:00.

Hello,

One option would be to create folders, let's say:

info_category/
info_brand/

...and then in those folders, upload .html files with your additional category and brand information; using the filenames like:

info_category/CategoryName.html
info_brand/BrandName.html

Then, wherever a category / brand is in context and you wish to display the extra content you can check for the file and display the content. For example, to display the extra category information at the top of the search results for that category; look for the following code towards the end of search.php:

if (isset($searchresults))

...and then INSERT something like this immediately BEFORE that code:

if ($parts[0] == "category")
{
  $filename = "category_info/".$parts[1].".html";
  if (file_exists($filename))
  {
    require($filename);
  }
}

If you're not sure of the equivalent code for brands, or how to access the category and/or brand in context at any point just let me know...

Hope this helps!

Cheers,
David.

Submitted by esogut on Fri, 2010-01-22 09:31.

Hi David isnt there a option to this through the database. i want to make also a edit page to make it easy so that other people also good work on it. and doesnt need to understand html.

Submitted by support on Fri, 2010-01-22 09:47.

Hi,

A database solution can be developed, bear with me and I'll look into it for you. Do you have/use phpMyAdmin for database administration?

Cheers,
David.

Submitted by esogut on Fri, 2010-01-22 14:47.

yep...

Submitted by support on Fri, 2010-01-22 15:03.

Hi,

That's great - setting up will be easier. There's quite a bit involved in creating a whole new admin section to manage your custom category / brand pages so please bear with me and I'll post some code for you to do this...

Cheers,
David.

Submitted by esogut on Fri, 2010-01-22 16:05.

Thnx David

Submitted by support on Mon, 2010-01-25 15:10.

Hi,

I've just put together a couple of category and brand info scripts, based on the category mapping scripts. Rather than post the code, i've uploaded the files here.

Unzip, and upload the files to your /admin/ folder.

Then, once only, browse to /admin/dbmod.php

To add links to the new tools to your admin menu, look for the following code on line 30 of includes/admin_menu.php:

  print "</small>";

...and REPLACE with:

  print "<a href='category_info.php'>Category Info</a>&nbsp;&nbsp;";
  print "<a href='brand_info.php'>Brand Info</a>&nbsp;&nbsp;";
  print "</small>";

Just like category mapping; you will be able to add new category / brand info pages, and click "Edit" to manage the content. To use; anywhere that a category is in context; such as the above example regarding search results; code similar to the following can be used:

if ($parts[0] == "category")
{
  $sql = "SELECT info FROM `".$config_databaseTablePrefix."category_info`
           WHERE name = '".database_safe($parts[1])."'";
  if (database_querySelect($sql,$rows))
  {
    print "<p>".$rows[0]["info"]."</p>";
  }
}

As before, if you're not sure where / what variable names to use to capture the category or brand in context, just let me know where you'd like to display the info and i'll show you what code to use...

Hope this helps!

Cheers,
David.

Submitted by scorpionwsm on Wed, 2010-02-17 10:27.

Hi
Is there an easy way to add this as a meta description in search.php?

Thanks

Submitted by support on Wed, 2010-02-17 13:52.

Hi,

Sure - look for where the title is set in search.php, around about line 50:

    $header["title"] = htmlentities($q,ENT_QUOTES,$config_charset);

...and at that point, you could add similar to the following:

    if ($parts[0]=="category")
    {
      $header["meta"]["description"] = "Category search results for ".$parts[1];
    }

Hope this helps!

Cheers,
David.

Submitted by scorpionwsm on Wed, 2010-02-17 15:38.

Cheers David that works perfectly,

Instead of having just the Category name would it be possible to include the text from the info field instead?

Thanks in advance.

Submitted by support on Wed, 2010-02-17 15:43.

Hi,

Sure - the code would be along the lines of:

    if ($parts[0]=="category")
    {
       $sql = "SELECT info FROM `".$config_databaseTablePrefix."category_info`
           WHERE name = '".database_safe($parts[1])."'";
       if (database_querySelect($sql,$rows))
       {
         $header["meta"]["description"] = $rows[0]["info"];
       }
       else
       {
         $header["meta"]["description"] = "Category search results for ".$parts[1];
       }
    }

Cheers,
David.

Submitted by scorpionwsm on Wed, 2010-02-17 16:34.

Sorry to be a pain David but when I use that code the Description displays perfectly but there are no products displayed on any of the category pages as can be seen on my test server {link saved} .

It also displays quite a few Undefined index: errors on my localhost.

I have uploaded a copy of my search.php for you at {link saved}

Thanks again

Submitted by support on Wed, 2010-02-17 16:43.

Hi,

Sorry about that - the code is overwriting the $sql variable that is already in scope - to fix this, in each of your sections to set meta tags, instead of $sql use $sql2, for example:

    if ($parts[0]=="category")
    {
       $sql2 = "SELECT info FROM `".$config_databaseTablePrefix."category_info`
           WHERE name = '".database_safe($parts[1])."'";
       if (database_querySelect($sql2,$rows))
       {
         $header["meta"]["description"] = $rows[0]["info"];
       }
       else
       {
         $header["meta"]["description"] = "Category search results for ".$parts[1];
       }
    }

That should be all it is...

Cheers,
David.

Submitted by scorpionwsm on Wed, 2010-02-17 16:46.

Brilliant David that works perfectly now.

Thanks

Submitted by kiddaclo on Mon, 2010-04-12 10:14.

Hi David,

Thanks for this mod it's just what I needed!

I'm using this mod for my brand pages would there be any way to only show the brand description on the first page of results? So when you use the pagination it's no longer there?

Cheers,
Chris.

Submitted by support on Mon, 2010-04-12 10:19.

Hi Chris,

Sure - for brand info text I assume that you're using

    if ($parts[0]=="brand")

...so you can simply replace that with:

    if (($parts[0]=="brand") && ($page==1))

Cheers,
David.

Submitted by kiddaclo on Mon, 2010-04-12 19:06.

David that's perfect!

Cheers,
Chris.

Submitted by cascadeclimbers on Tue, 2010-06-15 23:21.

Hi David,

I might have this questions answered by the time you get to this, but can the above easily be modified to work for the merchant pages as well? My guess is yes. Also, I'm assuming you can enter html into the info pages fields without problems.

Cheers, Jon
$> cd /pub
$> more beer

Submitted by cascadeclimbers on Wed, 2010-06-16 03:19.

Just wanted to follow up and say that I got the merchant code working no problem.

$> cd /pub
$> more beer