Forum

Thread tagged as: Problem, Docs, Runway

Empty output for a radio button value

Hi,

On the site I've build for a tent rental company I have tree different 'tents': safaritent, safaritent with bathroom and lodgetent. The URL for a specific campsite is built by Perch and is the camping location and If it is a safaritent with bathroom, it outputs the right url-with-bathroom.php The same with url-lodgetent. But if I want to select the safaritent there is no need for changing the URL. So, if the value is 'safaritent' this must NOT be added to the URL

If I just use an empty value there is a ID kind of number added to the URL If I use <if:else> with no value the same is happening.

Is there a way to suppress this value to be part of the output?

<tr>
    <td class="land">
    <perch:content id="land" label="land" type="select" options="Frankrijk, Spanje, Italië, Portugal, Duitsland, Nederland, Zweden" allowempty="true" />
    </td> 
    <td>
        <a href="https://www.tendi.nl/bestemmingen/<perch:content id="slug" type="slug" for="campingnaam" />
        <perch:content id="tentType" type="radio" label="tentType" options="safaritent|, safaritent met sanitair|-safaritent-met-sanitair, lodgetent|-lodgetent" />">
        <perch:content id="campingnaam" label"campingnaam" title="true" type="text" />
        <perch:if id="tentType" value="">
        </perch:if>
        <perch:if id="tentType" value="-safaritent-met-sanitair"> safaritent met sanitair
        </perch:if>
        <perch:if id="tentType" value="-lodgetent"> lodgetent
    </perch:if>
        </a>
</td>
    <td class="<perch:content id="za26" type="select" label="1 juli" options="closed, beschikbaar, laatste, bezet, aanbieding" allowempty="false" />"><a href="https://www.tendi.nl/bestemmingen/<perch:content id="slug" type="slug" for="campingnaam" /><perch:content id="url" type="slug" for="tentType" />"> </a></td>
    <td class="<perch:content id="za27" type="select" label="8 juli" options="closed, beschikbaar, laatste, bezet, aanbieding" allowempty="false" />"><a href="https://www.tendi.nl/bestemmingen/<perch:content id="slug" type="slug" for="campingnaam" /><perch:content id="url" type="slug" for="tentType" />"> </a></td>
    <td class="<perch:content id="za28" type="select" label="15 juli" options="closed, beschikbaar, laatste, bezet, aanbieding" allowempty="false" />"><a href="https://www.tendi.nl/bestemmingen/<perch:content id="slug" type="slug" for="campingnaam" /><perch:content id="url" type="slug" for="tentType" />"> </a>
    </tr>
<perch:content id="slug" type="slug" for="campingnaam" suppress="true" />
<perch:content id="url" type="slug" for="tentType" suppress="true" />

The page is live / in test at https://www.tendi.nl/beschikbaarheid

If you hover over second location (starnbosch - 1 July) you will see a value added to the URL because I did not put a decent value there. But at the same time if I put a text as value, the URL would not work anymore.

Olof Fredrikze

Olof Fredrikze 0 points

  • 4 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Where do those ID values come from? Do you recognise them as part of your content?

I'm not sure what ID values you mean but if you point at the 'code' that's added to the URL when the value is empty (which is not allowed for a radiobutton): that is random code.

But we managed to solve the problem just a lot of trial and even more error... In the end we came up with the use of type="composite" to ret the right content on the right spot.

<tr>
    <td class="land">
    <perch:content id="land" label="land" type="select" options="Frankrijk, Spanje, Italië, Portugal, Duitsland, Nederland, Zweden" allowempty="true" />
    </td> 
    <td>
        <a href="https://www.tendi.nl/bestemmingen/<perch:content id="slug" type="slug" for="campingnaam" /><perch:content id="tentType" type="radio" label="tent type" options="safaritent|,safaritent met sanitair|-safaritent-met-sanitair,lodgetent|-lodgetent" />">
        <perch:content id="campingnaam" label"campingnaam" type="text" />
        <perch:content id="urlType" type="composite" for="campingnaam tentType" join="" title="true" suppress="true" />
        <perch:if id="tentType" value="-safaritent-met-sanitair" > 
            safaritent met sanitair
            <perch:content id="fixed" type="composite" for="tentType" hidden="true" suppress="true"/>
        </perch:if>
        <perch:if id="tentType" value="-lodgetent" >
            lodgetent
            <perch:content id="fixed" type="composite" for="tentType" hidden="true" suppress="true"/>
        <perch:else />
            <perch:content id="fixed" type="composite" for="tentType" hidden="true" suppress="true"/>
        </perch:if>
        </a>
</td>
    <td class="<perch:content id="zo26" type="select" label="2 juli" options="closed, beschikbaar, laatste, bezet, aanbieding" allowempty="false" />"><a href="https://www.tendi.nl/bestemmingen/<perch:content id="slug" type="slug" /><perch:content id="fixed" type="slug" />">&nbsp;</a></td>
</tr>

Maybe there is some cleaning to be done but this seems to work trouble-free.

Thanks for the help

Drew McLellan

Drew McLellan 2638 points
Perch Support

If I just use an empty value there is a ID kind of number added to the URL

Those ones.

No, they are not content. Not sure where they come from. When I saved an entry all the codes generated from one template are the same - but random. Probably a database value??

If you are curious I can try to find out but the above pasted code works fine :D