Page 1 of 1

IF Anweisung im Template/Vorlage

Posted: Tue 23. May 2006, 22:23
by rasta74
Hallo zusammen,

ich benötige eine IF Anweisung (Wenn/Dann) im Template, bzw. in der Vorlage. Kann mir da jemand eine Hilfe geben?

Vielen Dank

Posted: Mon 29. May 2006, 08:10
by Pappnase
hallo

schreib mal genau was du willst! :-)
hast du vor bestimmte ebenen mit einem eigenen template zu versehen!?

Posted: Mon 29. May 2006, 09:07
by kubens
I solved this in one of my projects on this way:

Code: Select all

[PHP]
if ((isset($_REQUEST['show']) ? $_REQUEST['show'] : '') == 'templateA') {
echo <<<EOF_HTML
<h1>TemplateA<h1>
{CONTENT}
EOF_HTML;
}

elseif ((isset($_REQUEST['show']) ? $_REQUEST['show'] : '') == 'templateB') {
echo <<<EOF_HTML
<h1>TemplateB<h1>
{CONTENT}
EOF_HTML;
}

elseif ((isset($_REQUEST['show']) ? $_REQUEST['show'] : '') == 'templateC') {
echo <<<EOF_HTML
<h1>TemplateC<h1>
{CONTENT}
EOF_HTML;
}

else {
echo <<<EOF_HTML
<h1>TemplateDefault<h1>
{CONTENT}
EOF_HTML;
}
[/PHP]
Br
Wolfgang

Posted: Tue 30. May 2006, 19:41
by ff123
According to this post
http://www.phpwcms.de/forum/viewtopic.php?p=44526#44526
echoing the {content} block from within the [php] replacement tag won't work.

Posted: Sat 3. Jun 2006, 11:06
by kubens
I prepared a simple example. The template which is assigned to the structure contains the following source:

Code: Select all

<center>
[PHP]
if ((isset($_REQUEST['show']) ? $_REQUEST['show'] : '') == 'templateA') {
echo <<<EOF_HTML
<hr><h2 style="color:green">Template A</h2><hr>
{CONTENT}
EOF_HTML;
}

elseif ((isset($_REQUEST['show']) ? $_REQUEST['show'] : '') == 'templateB') {
echo <<<EOF_HTML
<hr><h2 style="color:blue">Template B</h2><hr>
{CONTENT}
EOF_HTML;
}

elseif ((isset($_REQUEST['show']) ? $_REQUEST['show'] : '') == 'templateC') {
echo <<<EOF_HTML
<hr><h2 style="color:red">Template C</h2><hr>
{CONTENT}
EOF_HTML;
}

else {
echo <<<EOF_HTML
<hr><h2 style="color:grey">TemplateDefault</h2><hr>
{CONTENT}
EOF_HTML;
}
[/PHP]
</center>
The article itself contains just one simple HTML content part:

Code: Select all

<p><a href="/test/doc1/">template <b>Default</b></a></p>
<p><a href="/test/doc1/?show=templateA">template <b>A</b></a></p>
<p><a href="/test/doc1/?show=templateB">template <b>B</b></a></p>
<p><a href="/test/doc1/?show=templateC">template <b>C</b></a></p>
It works perfect 8-)

Br
Wolfgang

Posted: Tue 6. Jun 2006, 11:01
by ff123
Try to setup a search content part for example and you will see the problems with this solution.