Challenge Posted March 23, 2007 Share Posted March 23, 2007 Hi all. Ive been wondering this, for quite some time. If i, for example, have a template where i want a number of entries to be while'd, outputting a long tables of names, for instance. How would anything allow me to do that when I'm using some sort of fast template/template class? The .tpl file will not be split into several parts, so how is it done? This would also apply to if statements, if i, for example, want to show some text to a logged in user, and another text to a user that's not logged in. Can anyone please explain? I really can't figure this out, and it sort of aggravates me Best regards Link to comment https://forums.phpfreaks.com/topic/43999-fast-templates-with-if-and-while-statements/ Share on other sites More sharing options...
Hell Toupee Posted March 23, 2007 Share Posted March 23, 2007 You actually use THREE templates. 1 header template, which you display first which will have all of the table information before the rows. 1 content template that will be iterated, containing just the row of information that is to be repeated so many times. 1 footer template that will be displayed after the while loop, ending the table, chances are it'll just be "</table> Link to comment https://forums.phpfreaks.com/topic/43999-fast-templates-with-if-and-while-statements/#findComment-213629 Share on other sites More sharing options...
Challenge Posted March 23, 2007 Author Share Posted March 23, 2007 I'm sorry, that was actually not exactley what i meant I allready have, like you say, 3 templates. Though the middle one contains a lot more than just the table that is going to be repeated, but also an additional menubar a loginbox etc. All these elements should remain in the body.tpl file, though i want to repeat some part of the HTML, and only show the loginbox to the users not logged in (And then show another to those logged in). I've looked into smarty, but thats not really for me, as i want a much smoother syntax - the while's and if's could for example be defines by <!-- IF BEGIN: LOGINBOX_LOGGED_OUT --> *loginbox* <!-- IF END: LOGINBOX_LOGGED_OUT --> <!-- IF BEGIN: LOGINBOX_LOGGED_IN --> *Logged in menu* <!-- IF END: LOGINBOX_LOGGED_IN --> Same method could apply to while statements. Even though, thank you very much for your reply! I'm sorry that i was a little vague explaining my problem. Link to comment https://forums.phpfreaks.com/topic/43999-fast-templates-with-if-and-while-statements/#findComment-213639 Share on other sites More sharing options...
Hell Toupee Posted March 23, 2007 Share Posted March 23, 2007 I meant 3 templates within body.tpl, so that all that is left is what needs to be iterated while the rest is constant. A page on your site could be made up of the following templates: show header.tpl if ($online=="yes"){ show body_top_online.tpl }else{ show body_top_offline.tpl } show body_middle.tpl show body_bottom.tpl show footer.tpl Where body_top_online or body_top_offline both fit in with body_middle, in that they have the same table structure, but different information shown on them. This is all psuedo code because I don't know what your actual code looks like but what you want to do is fairly simple. Link to comment https://forums.phpfreaks.com/topic/43999-fast-templates-with-if-and-while-statements/#findComment-213649 Share on other sites More sharing options...
Challenge Posted March 23, 2007 Author Share Posted March 23, 2007 Ahh, okay now it get it But, really, that is pretty much something i would like to avoid - I would rather have the boxes and the <!-- start -->-like syntax in one file - It was sort of the "core" method, as i think i would learn some new stuff this way. Please don't take this as i don't appreciate your help, because I really do. I am, unfortunately, looking for another method, as described in my previous post. Really, the reason not to use the method you described is, that it would, for me, not really make sense. Then i could "just" do in line HTML, as i used to. But anyway, thank you very much for your help. I'm sorry, if I wasted your time (Don't get me wrong - you didn't wast mine, and I appreciate your help). Best regards Link to comment https://forums.phpfreaks.com/topic/43999-fast-templates-with-if-and-while-statements/#findComment-213711 Share on other sites More sharing options...
Challenge Posted March 24, 2007 Author Share Posted March 24, 2007 Front page bump Link to comment https://forums.phpfreaks.com/topic/43999-fast-templates-with-if-and-while-statements/#findComment-214200 Share on other sites More sharing options...
Challenge Posted March 24, 2007 Author Share Posted March 24, 2007 Sorry - once more Anyone knows? Link to comment https://forums.phpfreaks.com/topic/43999-fast-templates-with-if-and-while-statements/#findComment-214457 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.