rlelek Posted November 18, 2008 Share Posted November 18, 2008 Hello everyone! I was just curious how I would go about implementing a dynamic header/footer in Smarty/PHP5 I cannot use the smarty 'include file="header.tpl"' function because I need logic applied to the template. Since the whole point of smarty is to separate these, i really would like to figure this out... and i don't want to use tags in the template. Would I have to access the necessary header/footer data in the business layer for the specific page and then, in the template layer, include those two templates (header/footer) and pass them an array of data to use? I would rather not write "<?php include_once('header.php') ?>" in every script just to get the header logic. Also, even if I did do it by this method, what happens when there are multiple smarty objects? I know each object is separate, but what happens when there is more than one "display" method envoked? example ... [code] // header.php <?php $header = new Smarty; // do all the array assignments [b]$header->display('header.tpl');[/b] ?> // footer.php <?php $footer = new Smarty; // do all the array assignments [b]$footer->display('footer.tpl');[/b] ?> // index.php <?php include_once('header.php'); ?> <?php $index = new Smarty; // do all the array assignments [b]$index->display('index.tpl');[/b] ?> <?php include_once('footer.php'); ?> How would those triple display statements work? Sorry for all these questions, but i've just been so confused Thanks in advance... Link to comment https://forums.phpfreaks.com/topic/133155-smarty-include-header-file-with-business-logic/ Share on other sites More sharing options...
DarkWater Posted November 18, 2008 Share Posted November 18, 2008 What kind of dynamic header/footer are you talking about exactly? Your plan of action would completely depend on what you're actually trying to achieve. Link to comment https://forums.phpfreaks.com/topic/133155-smarty-include-header-file-with-business-logic/#findComment-693067 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.