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

Link to comment
https://forums.phpfreaks.com/topic/272059-ifelse-help/
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
https://forums.phpfreaks.com/topic/272059-ifelse-help/#findComment-1399683
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
https://forums.phpfreaks.com/topic/272059-ifelse-help/#findComment-1399684
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.