Help - Search - Members - Calendar
Full Version: Template Conditionals
Invision Power Services > Community Forums > Community Web Design and Coding
=Charles
I'm very stuck on how to go about coding template conditionals. I want to use a very simple method.

Let's just say I want a particular part of a template to loop while I build each item in it. How could I go about doing that?

CODE
<h1>A Header</h1>
<ul>
    <loop><li>$variable</li></loop>
</ul>


So then in the example above I would want to loop through a list. Let's imagine the above template is in a string called $page. How would I use $page and then create my list inside it. I am not so good with regular expressions.

Thanks in advance to any replies. original.gif
Wombat
You might want to take a look at WACT. It supports exactly what you're asking and more.

[WACT]: List Tag
princetontiger
You could use:
CODE
<ul>
    <?php foreach ( $templates as $templet ): ?>
    <li><?php echo $templet; ?></li>
    <?php endforeach; ?>
</ul>


http://us4.php.net/manual/en/control-struc...tive-syntax.php

You don't have to use regular expressions if you don't want to... you could just use an output buffer, etc.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.