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
IF Anweisung im Template/Vorlage
I solved this in one of my projects on this way:
Br
Wolfgang
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]
Wolfgang
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.
http://www.phpwcms.de/forum/viewtopic.php?p=44526#44526
echoing the {content} block from within the [php] replacement tag won't work.
-- Vuurvos --
I prepared a simple example. The template which is assigned to the structure contains the following source:
The article itself contains just one simple HTML content part:
It works perfect
Br
Wolfgang
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>
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>
Br
Wolfgang