Jump to content

[SOLVED] templating + function calls is it possible?


pkedpker

Recommended Posts

My question may seem odd to some people who don't know what templating is..

 

My site before templating was a real mess a bunch of php tags and html code in each php file.. so I looked for a solution and found templating is what i need..

 

Now i can do nearly everything with templating that is call variables in it.. but I cannot seem to find a way to do functions..

 

basically here is what I do

 

loadTemplate(blahblah)
	$t = file_get_contents($templateName);
	return "return <<<TMP\r\n\r\n{$t}\r\n\r\nTMP;\r\n";

 

now index is like

<?php
session_start();
echo eval(loadTemplate('header'));
echo eval(loadTemplate('footer'));
?>

 

 

a template file is basically simple HTML coded website with support for variable with the use of {$varName}

 

its a combination of heredoc and eval..

 

well anyways I want to know how to call functions in it.

 

how would i call like

my old way of doing this

          <?php showMemberOptions(); ?>

 

in a template?

 

I tried

{showMemberOptions()}

 

It just echos {showMemberOptions()}

 

 

 

I know somehow I could cuztomize the showMemberOptions function into a template with a shitload of new variables but that will be pretty crazy for me.. since showMemberOptions can show login form.. or welcome username and a bunch of other stuff..

Link to comment
Share on other sites

haha this cost me enough trouble converting it all to template system.. but now i can support many different styles on the website and not like my previous idea where I just had to modify a CSS file to change my site looks completely now I can actually move things around in all different designs with a set of different html templates.. and plus now my other site designers who are like 11-15 years old only understand html/css they can pick this up easily.

 

I can see a big downside to templating.. you have to make many variables for everything.. can't just echo things out like I used to do.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.