Forum

Thread tagged as: Question, Problem, Error

Radio buttons with dynamic output

Now I got the idea behind multiple templates within perch :)

But still have trouble with this one: When I select the radio button "custom" in my perch backend, it still output both, the day of the week and my custom text.

My Template:

<perch:content id="cocktailbar" type="radio" label="Wie hat die Cocktailbar heute geöffnet?" options="Normale Öffnungszeiten|today, Spezielle Öffnungszeiten|custom" suppress="true" />

<perch:if id="today" value="Sunday">
    Sonntag<perch:content id="sunday_cocktailbar" type="text" label="Sonntag" />
</perch:if>

<perch:if id="today" value="Monday">
    Montag<perch:content id="monday_cocktailbar" type="text" label="Montag" />
</perch:if>

<perch:if id="today" value="Thusday">
    Dienstag<perch:content id="tuesday_cocktailbar" type="text" label="Dienstag" />
</perch:if>

<perch:if id="today" value="Wednesday">
    Mittwoch<perch:content id="wednesday_cocktailbar" type="text" label="Mittwoch" />
</perch:if>

<perch:if id="today" value="Thursday">
    Donnerstag<perch:content id="thursday_cocktailbar" type="text" label="Donnerstag" />
</perch:if>

<perch:if id="today" value="Friday">
    Freitag<perch:content id="friday_cocktailbar" type="text" label="Freitag" />
</perch:if>

<perch:if id="today" value="Saturday">
    Samstag <perch:content id="saturday_cocktailbar" type="text" label="Samstag" />
</perch:if>

<perch:if id="cocktailbar" value="custom">
    <perch:content id="custom_cocktailbar" type="text" label="Spezielle Öffnungszeiten" />
</perch:if>

My HTML:

<?php
    PerchSystem::set_var('today', date('l'));
    perch_content_custom('Öffnungszeiten Cocktailbar', [
        'template' => 'dynamically_cocktailbar.html',
    ]);
?>
Andreas Gücklhorn

Andreas Gücklhorn 0 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Do this instead:

<perch:content id="cocktailbar" type="radio" label="Wie hat die Cocktailbar heute geöffnet?" options="Normale Öffnungszeiten|today, Spezielle Öffnungszeiten|custom" suppress="true" />

<perch:if id="cocktailbar" value="custom">
    <perch:content id="custom_cocktailbar" type="text" label="Spezielle Öffnungszeiten" />
<perch:else />

<perch:if id="today" value="Sunday">
    Sonntag<perch:content id="sunday_cocktailbar" type="text" label="Sonntag" />
</perch:if>

<perch:if id="today" value="Monday">
    Montag<perch:content id="monday_cocktailbar" type="text" label="Montag" />
</perch:if>

<perch:if id="today" value="Thusday">
    Dienstag<perch:content id="tuesday_cocktailbar" type="text" label="Dienstag" />
</perch:if>

<perch:if id="today" value="Wednesday">
    Mittwoch<perch:content id="wednesday_cocktailbar" type="text" label="Mittwoch" />
</perch:if>

<perch:if id="today" value="Thursday">
    Donnerstag<perch:content id="thursday_cocktailbar" type="text" label="Donnerstag" />
</perch:if>

<perch:if id="today" value="Friday">
    Freitag<perch:content id="friday_cocktailbar" type="text" label="Freitag" />
</perch:if>

<perch:if id="today" value="Saturday">
    Samstag <perch:content id="saturday_cocktailbar" type="text" label="Samstag" />
</perch:if>

</perch:if>

Thank you Drew, you did it!

My site is now fully powered with Perch and I'm a happy customer!

I can recommend Perch to all my co-workers and clients. The support behind it is just awesome.

Sincerly, Andreas.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Great, thanks!