Hi David, thanks for the help with my questions earlier this week.
I am sure the answer to my new question is somewhere in the forum, but the closest I could find is node 2278.
I have a left side menu displaying categories. When a category link is clicked, I would like the category results page to include an html file specific to that category inserted near the top of the page. I have created a directory for the individual html files.
Did this on index page by creating an into.html and using
}
require("html/intro.html");
if (isset($featured)) require("html/featured.php");
require("http://appliance-sales.com/html/footer.php");
?>
Just not sure where or how to call for custom files specific to each category.
Thank you in advance and Have a Great weekend! Diana
well, no luck so far, but I was having server issues and could not figure out why each morning, the site would not load. Your comment about URL taught me something and saved a lot of frustration.
As far as the code you recommended for displaying content on category pages, I copied it directly into search.php and created a folder in the root with an html file inside, named after a category. When clicking on that category link, the new file does not show up on the category page.
insertion on search.php
require("html/header.php");
require("html/menu.php");
require("html/searchform.php");
require("html/banner.php");
if ($parts[0]=="category")
{
$filename = "cathtml/".$parts[1].".html";
if (file_exists($filename))
{
require($filename);
}
}
if (isset($searchresults))
{
if ($searchresults["numRows"])
{
require("html/searchresults.php");
}
else
{
require("html/noresults.php");
}
}
if (isset($navigation)) require("html/navigation.php");
require("html/footer.php");
?>
thanks, Diana
Hi Diana,
The code looks fine - did you include the ".html" on the end of each of the files, so that you would have, for example:
Electronics.html
Cheers,
David.
Hi Diana,
Should be straight forward. Assuming that you have created a folder called "cathtml", and in that folder are files called "category name.html", then you could add this code towards the end of search.php in amongst the calls to the other /html/ modules:
if ($parts[0]=="category")
{
$filename = "cathtml/".$parts[1].".html";
if (file_exists($filename))
{
require($filename);
}
}
Also note that when using require(), you should not specify a URL as this will (if URL wrappers are enabled on your server) only include the parsed output and potentially cause performance issues are the script must make an entire HTTP connection in order to retrieve the content!)
Cheers,
David.