 |
Smarty
The discussions here are for Smarty, a template engine for the PHP programming language. Dedicated server web hosting provided by Guru-host.eu. |
| View previous topic :: View next topic |
| Author |
Message |
mike-p87 Smarty Rookie
Joined: 12 Mar 2010 Posts: 6
|
Posted: Fri Mar 12, 2010 5:35 pm Post subject: Smarty inject html before display |
|
|
Hey Guys,
Im a newbie to Smarty but it is FAN-DABI-DOZY! Great job....
So i am really stuck on this. I am building a CMS system and I am planning on using this template engine.
So users will create there own templates in .html format. Now this is all great and works fine.
However, i want to inject my CMS menu and tools on those pages. So in fact the code will basically insert my CMS header into the <head></head> section of there template. And some JS just on top of the </body> element.
Right now i am using a custom tag {$init_portal} but this is not good. I dont want the user to keep adding that on there templates.
Any ideas....
If tried doing something like this .....
| Code: |
//Get the template init
$init = $smarty->fetch($_SERVER["DOCUMENT_ROOT"].'/<my path>/init.portal.php');
// do some replace elements here
..... $myNewTemplate = some repace stuff....
$test = $smarty->display($myNewTemplate);
However display is expecting a file path not string.
| [/code] |
|
| Back to top |
|
mike-p87 Smarty Rookie
Joined: 12 Mar 2010 Posts: 6
|
Posted: Fri Mar 12, 2010 6:21 pm Post subject: Inheritance |
|
|
Would inheritance work..
Will this include the parent header in the child template when rendered?
e.g.
[code]
parent.tpl
<html>
<head>
Portal Head
</head>
<body>
Portal Body
</body>
</html>
[code]
child.tpl
User template
child.tpl
<html>
<head>
Designer head
</head>
<body>
Designer Head
</body>
</html>
$smarty->display('extend:parent.tpl|child.tpl');
[/code] |
|
| Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|