Category and Brand infopages
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
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.
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.
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.
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> ";
print "<a href='brand_info.php'>Brand Info</a> ";
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.
Hi
Is there an easy way to add this as a meta description in search.php?
Thanks
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.
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.
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.
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
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.
Brilliant David that works perfectly now.
Thanks
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.
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.
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
Just wanted to follow up and say that I got the merchant code working no problem.
$> cd /pub
$> more beer
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.