gckmac Posted December 16, 2012 Share Posted December 16, 2012 (edited) For SEO purposes, I need to have a different header for the different portfolio pages generated on the following site: The primary page http://tcnyc.com/portfolio.php invokes the following, based on vf_category: http://tcnyc.com/por...egory=Bathrooms http://tcnyc.com/por...tegory=Kitchens The code at portfolio_category.php uses the following to set the header: //Show header $template_header = new HTML_Template_IT(); $template_header->loadTemplateFile("parts/header.tpl",true,false); $template_body->setVariable('header', $template_header->get()); The problem is the 2nd item, where parts/header.tpl is fixed. I need to use Bathroomsheader.tpl for bathrooms, Kitchensheader.tpl for kitchens, etc. (or some similar nomenclature). This is because the header (with Title & Description tags) needs to change based on category. The existing code is: <?php $vc_root_friendly = '.'; $vc_root_site = '.'; include_once("$vc_root_site/config.php"); include_once("$vc_includes_folder/IT.php"); $template_body = new HTML_Template_IT(); $template_body->loadTemplateFile("tpl_portfolio_category.html"); include_once("$vc_includes_folder/images.php"); if(!isset($_REQUEST['vf_category'])){ header("location:portfolio.php"); die(); } //Show header $template_header = new HTML_Template_IT(); $template_header->loadTemplateFile("parts/header.tpl",true,false); $template_body->setVariable('header', $template_header->get()); //Show footer $template_footer = new HTML_Template_IT(); $template_footer->loadTemplateFile("parts/footer.tpl",true,false); $template_body->setVariable('footer', $template_footer->get()); $template_body->setVariable("image_category", $_REQUEST['vf_category']); //Select photos for this category $vl_photos = $DB->q("SELECT * FROM $vc_prefix"."photo_gallery WHERE category = '$_REQUEST[vf_category]' ORDER BY id_photo"); //Show photos etc. Does anyone know how to modify this code such that the vf_category pulled from the database can cause includes of the correct header.tpl? I know that it will involve if & else commands, i.e., if vf_category = Bathrooms, then use header name A, else use head name B, etc. Thanks in advance! gckmac Edited December 16, 2012 by gckmac Quote Link to comment Share on other sites More sharing options...
gckmac Posted December 16, 2012 Author Share Posted December 16, 2012 I should add that the invoked file tpl_portfolio_category.html also references header.tpl: <? include_once 'parts/header.tpl'; ?> {header} <table width="100%" cellspacing="0" cellpadding="0" border="0"> <tr> <td class="main"><h1><span class="firstLetter">{image_category}</span></h1> <p> </p> <table height="89" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td colspan="7"> </td> </tr> <!-- BEGIN block_thumb --> <tr> <td width='180' height="120" background="./images/thumb-bg.gif"> <div align="center">{thumb1}</div></td> <td width="10"> </td> <td width='180' background="./images/thumb-bg.gif"> <div align="center">{thumb2}</div></td> <td width="10"> </td> <td width='180' background="./images/thumb-bg.gif"> <div align="center">{thumb3}</div></td> <td width="10"> </td> <td width='180' background="./images/thumb-bg.gif"> <div align="center">{thumb4}</div></td> </tr> <tr valign="bottom"> <td height="3"></td> <td height="3"></td> <td height="3"></td> <td height="3"></td> <td height="3"></td> <td height="3"></td> <td height="3"></td> </tr> <!-- END block_thumb --> </table> <br> <img src="images/spacer.gif"></td> </tr> </table> {footer} Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted December 16, 2012 Share Posted December 16, 2012 This is the definition of a computer based template - A document or file having a preset format, used as a starting point for a particular application so that the format does not have to be recreated each time it is used You should only have one header.tpl file that determines the format/layout of your header. You would set the title and description values that are put into the header.tpl template, not select between two different template files. Quote Link to comment Share on other sites More sharing options...
gckmac Posted December 16, 2012 Author Share Posted December 16, 2012 (edited) The problem is that having only 1 header include means that the Title & Description tags cannot change for the relevant page. This was bad coding for SEO purposes. Workaround is IF/ELSE, but having trouble implementing. Edited December 16, 2012 by gckmac Quote Link to comment Share on other sites More sharing options...
Christian F. Posted December 16, 2012 Share Posted December 16, 2012 Yes, they can. Just like any other content on the page. You just need to set a template variable for each, containing the desired output. Quote Link to comment Share on other sites More sharing options...
Jessica Posted December 16, 2012 Share Posted December 16, 2012 Did you notice that the title of this page is different than all the others? Clearly it's possible. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted December 16, 2012 Share Posted December 16, 2012 @gckmac, The 'Report' button in a post is for reporting problems with a post, not making a replying to the post. Quote Link to comment Share on other sites More sharing options...
gckmac Posted December 16, 2012 Author Share Posted December 16, 2012 It was a mistake to push the Report button. And I fully agree with Gurus. I've done this many times but am just having trouble in this instance. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.