By: Mark
Date: 2006-01-24
Time: 06:26
|
How to load multiple templates?I'm new to PHP and TBS and have searched the Examples and this forum for help... I can't figure out how to load multiple HTML templates.
For instance, I have templates named "header.html", "sidebars.html", "content.html" and "footer.html". What is the best way, or what is the best code to include them all in $TBS->LoadTemplate method to show the complete page? Thanks, Mark |
||||
By: Skrol29
Date: 2006-01-24
Time: 14:52
|
Re: How to load multiple templates?Hello Mark,
There is a good example that shows how to do this. Just go to the Example page online, and try the "Sub-templates" example. |
||||
By: Mark
Date: 2006-01-24
Time: 20:08
|
Re: How to load multiple templates?Thanks for your response. The examples page is not clear and incomplete so that is why I asked how to load multiple templates here in the forum.
I know it must be quite simple since TBS is a template engine, but the subtemplate example pages don't show the php [onload= code, nor anything related to how TBS loads several templates. The examples pages are incomplete and useless to all, except the experts. Do I need to be Sherlock Holmes (or an expert) to load several files into one page? If so I've been wasting my time as have others who don't "get it" right away. |
||||
By: Mark
Date: 2006-01-24
Time: 21:14
|
Re: How to load multiple templates?Let me try again... The "Examples" pages look like "Reference" pages to me--since I am new to TBS and PHP. The examples shown are not working examples at all. Will someone help me complete the code below to load 4 templates into one page:
Thanks, Mark |
||||
By: Tom
Date: 2006-01-25
Time: 00:30
|
Re: How to load multiple templates?Mark,
The 'sub-template' example being referred to is at http://www.tinybutstrong.com/examples.php The are NOT demo pages -- thay are an actual working example -- as are all of the examples. The 'sub-template' example in link above does exactly what you appear to have asked for. Set up the exact example and get it working on your server to begin with -- then morph it for your application |
||||
By: Tom
Date: 2006-01-25
Time: 00:36
|
Re: How to load multiple templates?Remember to use the selections in the "Display:" menu ( upper left ) to see each of the aspects in turn.
|
||||
By: Skrol29
Date: 2006-01-25
Time: 00:49
|
Re: How to load multiple templates?Hello Mark,
Tom is rigth, online examples are really true live TBS applications. Adding subtemplates is not managed in the PHP side, but in the HTML side. Just take a look at the example and select "Html template" in the "Display" Box. You will see how subtemplates are placed in the main template, and how you can deal with Php variables for it. |
||||
By: Skrol29
Date: 2006-01-25
Time: 00:52
|
Re: How to load multiple templates?Note: there is also a more advanced mode for managing subtemplate at the PHP side too. But this needs some good knowledge of TBS, and it is relative to parameter "subtpl". This parameter is explain in the manual.
|
||||
By: Mark
Date: 2006-01-25
Time: 04:03
|
Re: How to load multiple templates?I appreciate everyone taking the time to help me. Thanks everyone!
I still can't get it working though. I can load one of my four templates but not the others. I can't get enough working code from the examples to make it work. I'm giving up now since I can't find the answer. But thanks. |
||||
By: Mark
Date: 2006-01-25
Time: 05:21
|
Re: How to load multiple templates?I have read back through the posts here and I realized that I wasn't clear in what I'm trying to do.
I am trying to load 4 templates to assemble one html page.... from the php side ONLY. Is this not what a template engine is meant for? Anyway, the Manual nor the Examples pages do not explain this well at all. If I was the author of the program I would know how to do this, but I am not. Thats why I'm here asking for help. Please don't suggest that I read more "Examples" because I* have read them all and the Manual too. I have read several posts in this forum where others have asked the same question I have, and it was never directly answered by anyone. So... Can anyone show me directly in the php code below how to accomplish this?
|
||||
By: Skrol29
Date: 2006-01-25
Time: 21:10
|
Re: How to load multiple templates?Hi Mark,
You're not giving lot of clue to be helped. What seems obvious for you is not for us/me. All Template Engines are working by merging data, not concatenate them. That is the point. If what you're trying to do is loading a main template which must be built by concatenating 4 parts first, then here are several ways to do it. Way #1: using a global main template main.txt :
Way #2: loading template parts step by step:
Way #3: building the source at the PHP side (this is not following the Template Engine philosophy)
|
||||
By: Mark
Date: 2006-01-26
Time: 07:05
|
Re: How to load multiple templates?Thank you Skrol29! Methods #1 and #3 are both great for what I need to do from the PHP side. I must be the only one needing to do this... :-)
I need to choose which templates to pair up with each other at runtime, depending on several factors, so all pieces (or mini-templates) of each page loading must come from PHP instructions and NOT [onload;file=[?]] tags within the templates. It's different I know... but thats what I need to do. Your examples are excellent and it is clear to me now how TBS works! Having mastered several programming languages (but until now NEVER! touching PHP) I wasn't grasping the framework of TBS, so was struggling. Your above examples make everything else about the way the program works very clear to me now. Thank you very much!!! Again! ps. This example would be a great addition to your "Examples" pages, as I'm sure I'm not going to be the last person to ever ask about this... |
||||
By: martijn
Date: 2007-06-30
Time: 10:49
|
Re: How to load multiple templates?Hi,
I've been wanting to do something like this, too. My templates are set up like the following: - header.html (constant); - a variable template being passed through LoadTemplate with .html-extension; - footer.html (constant) Currently I get this to work with the [onload;file] method for subtemplates but I'm not so happy with that. I'd much rather have LoadTemplate load the header, variable template and then footer at the PHP side without having to specify the onload/onshow command. But the header and footer files must still be able to contain parsable command tags (those between straight brackets). What would be the best way to achieve this? Thanks in advance! |