tags:

views:

36

answers:

1

I'm hoping I can get a definite answer on this. I will try and explain this as best I can.

I have a main template file that contains everything I want. In a small area within this template, I want to echo the view that is associated with the link that the user clicks on. This is not a problem so far however, when I have to use a loop data it is not so easy anymore.

If I have this as my template:

table
tr
td><?php echo $myContent; ?></td
/tr
/table

You can clearly see how I would be able to echo the values of the variable. Now, suppose that I wanted to show the user something that required multiple rows of data. I would then have to use a loop. So, you see, it depends on the content that I want to display that determines what construct to use within the HTML.

Can someone please help me to figure this out? I'm sure this is just me not correctly understanding how this should be done.

Thanks

A: 

Have a HTML files with custom tags of your own.

say template.html:

<div><$content$></div>

when processing the output, you take the contents of template.html and parse it:

$replace = array();
$replace['<$content$>'] = $pagecontents;
$template = file_get_contents('template.html');

$output = str_replace(array_keys($replace),$replace,$template);

Adapted from http://code.google.com/p/samstyle-php-framework/.

thephpdeveloper
Thanks for the link. I just had a look at it but this new framework is a bit different than what I am using. Within my controller, I call the view and the variables within the controller are passed to the view. I don't see how this will help. Are you familier with Cake? This functions exactly the same way.
Jim
I just downloaded that framework that you linked to and it crashed my server over and over again. :) I couldn't even get it to load.
Jim