Jump to content

If/else Help


gckmac

Recommended Posts

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 by gckmac
Link to comment
Share on other sites

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}

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 by gckmac
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.