IF Anweisung im Template/Vorlage

If you have created additional (non official) documentation or tutorials or something like that please post this here
Post Reply
rasta74
Posts: 1
Joined: Tue 23. May 2006, 22:21

IF Anweisung im Template/Vorlage

Post 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
Pappnase

Post by Pappnase »

hallo

schreib mal genau was du willst! :-)
hast du vor bestimmte ebenen mit einem eigenen template zu versehen!?
kubens
Posts: 168
Joined: Sat 6. Nov 2004, 15:29
Location: Duesseldorf near Cologne ;-)

Post 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
ff123
Posts: 172
Joined: Thu 9. Jun 2005, 20:03
Location: The Netherlands
Contact:

Post 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.
-- Vuurvos --
kubens
Posts: 168
Joined: Sat 6. Nov 2004, 15:29
Location: Duesseldorf near Cologne ;-)

Post 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
ff123
Posts: 172
Joined: Thu 9. Jun 2005, 20:03
Location: The Netherlands
Contact:

Post by ff123 »

Try to setup a search content part for example and you will see the problems with this solution.
-- Vuurvos --
Post Reply