Forum Moderators: coopster

Message Too Old, No Replies

Nest Variables and HTML

How do I use a block of HTML as a variable and use a variable in the HTML

         

calvinmicklefinger

10:48 pm on Jan 20, 2005 (gmt 0)

10+ Year Member



I am creating a template for some content based pages. I want the included content to contain all of my needed information, such as meta tags, page title, keywords, etc., so I will only have to create one page for each topic (lot's of topics on one subject). I am using this method because don't know databases.

At the top of my wrapper.php page (the template), I place the following ...

<?
// Start the session and register the variables
SESSION_START();
header("Cache-control: private");
SESSION_REGISTER("EmptyField");
SESSION_REGISTER("Affiliate");
SESSION_REGISTER("LandingPage");
SESSION_REGISTER("CurrentPage");

$URL_data = explode("/", getenv("REQUEST_URI"));

// Get tracking information form the URL array
$_SESSION['EmptyField'] = $URL_data[0] ;
$_SESSION['Affiliate'] = $URL_data[1] ;
if ($LandingPage == "") {$_SESSION['LandingPage'] = $URL_data[2] ; }
$_SESSION['CurrentPage'] = $URL_data[2] ;

// Fill in the blanks on the page header
$ThisPageName = ucfirst($CurrentPage);
include $CurrentPage . '.php' ;
?>

And then in the cell where I need the content, I use the following ...

<td><br>
******************** Variable appears below ********************
<? echo $var2?>
</td>

The contents of a content file may contain items such as this ...

<? $var1="Some Content"?>

<? $var2 = '
<br>
Empty Field? = <?php echo $EmptyField;?><br>
Affiliate Num? = <?php echo $Affiliate;?><br>
Landing Page? = <?php echo $LandingPage;?><br>
Current Page? = <?php echo $CurrentPage;?><br>
'?>

The variables $var1 and $var2 are called and placed in their appropriate locations, however the php script in the variable $var2 is not parsed, and does show in the source as unprocessed php code, but does not show in the browser.

I have tried the variable with single and double quotes. Is there another function I should consider, and how would I use it?

Many thanks.

jusdrum

11:32 pm on Jan 20, 2005 (gmt 0)

10+ Year Member



Have you looked into Smarty? Smarty is a great PHP templating system that is really easy to learn, and will solve some of your problems. Check out [smarty.php.net...]

calvinmicklefinger

12:10 am on Jan 21, 2005 (gmt 0)

10+ Year Member



I've seen Smarty pop up every now and then, and am printing the manual now. Can I learn it in a day or two?