Hi everyone i currently have this system for templating in my product; function get_template($template_name) { global $site_config; $tn = 'templates/' . $site_config['template'] . '/' . $template_name . '.html'; if (file_exists($tn)) { $t = file_get_contents($tn); return "return <<<TMP\r\n\r\n{$t}\r\n\r\nTMP;\r\n"; } else { error($lang['title']['error'], $lang['text']['template_not_found']); } } PHP: What i want to do is to be able to have something like this in a template {block: show_msn} someones msn address here {/block: show_msn} PHP: So i would put in a file; // msn doesnt = nothing meaning user has an msn address put in if ($user_info['msn'] != "") { use_block('show_msn'); } PHP: Any ideas on how i would adapt my templating to use blocks? (would also be useful for repeating parts of a template file).
You should put that 'if user info' inside the template that always gets called, in a sub-template. If you put a final block (output html) with a variable that has to be loaded then every page you generate will have to do that. It is just something to watch for. I'm not much with templates. I was using phpWebsite, which is free, for a while and they have a system of blocks that each user (that signs in) can comfigure for themselves. Perhaps you could look at that system. There are about twenty-some blocks that you add to your page in admin, the usual - navigation, posts, forms - but all kinds of RSS feeds and everything. I was looking before, also, at a tute on Codewalkers that showed haw to build up templates. It's pretty besic, though. Another idea is to get Smarty. It has all the instruction with the download - really pretty good, aas far as I remember. You are over my head so I just wanted to throw a couple of ideas - just in case
I dont mean blocks as in different aspects like header, nav, footer....i mean for looping variables from one block of code (for showing the same formatting multiple times for different things, like a members list page, each members row would be a looped block it saves me making a template file with the table tags, a template file with a members row in and then another template file to end the table) And my example if the user has an msn set in profile then display the msn box.
Yeah, I see what you mean, I am not very good with php code and loading variables. I do hope someone else can help you, though. But, I work with the scripts a lot, and if I see something like that here quick, I will let you know