0

I can not get the fields of a channel to be fused in a form.

I created a Partial Template with the following code:

{sidebar}

<form action="{path='{s_url}/{s_url_search}'}" method="GET" id="">
<div class="form-group">
    <label>Contratto</label>
    <select class="form-control" name="contratto">
        <option value="all">Tutti i contratti</option>
        <option value="Vendita">Vendita</option>
        <option value="Affitto">Affitto</option>          
    </select>
</div>
<div class="form-group">
    <label>Comune</label>
    <select class="form-control" name="comune">
        <option value="all">Tutti i comuni</option>
        {exp:channel:entries channel="comuni"}
        <option value="{title}">{title}</option>
        {/exp:channel:entries}            
    </select>
</div>
<div class="form-group">
    <label>Tipologia</label>
    <select class="form-control" name="tipologia">
        <option value="all">Tutte le tipologie</option>
        {exp:channel:entries channel="tipologie"}
        <option value="{title}">{title}</option>
        {/exp:channel:entries}        
    </select>
</div>
<button type="submit" class="btn btn-sm btn-primary">Cerca</button>

This works if the url is of type mysite.it/Template_Group_name/Template.

It does not work instead if the url is of type mysite.it/Template_Group_name/Template/item

I give an example. I have the Blog Channel where I have the articles inside. example article: Hello Worl The code written above works if I go to mysite.it/blog/all Which shows all the articles But it does not work for mysite.it/blog/view/hello_world showing the article

Link info: https://docs.expressionengine.com/latest/urls/url_structure.html#entries-and-other-things

The template all and the template view inside are very similar to each other only the channel display changes but for all the form is shown with the generation of the fields from the other channels but it does not work if the url also has the name of an article.

What is wrong? I also copy the view channel code.

Picture mysite.it/template => mysite.it/immobili the Partial Template works fine. Example

{exp:channel:entries channel="comuni"}
    <option value="{title}">{title}</option>
    {/exp:channel:entries}

this code works and generate the field's option.

enter image description here

Instead into picture mysite.it/template_group/template/my_url_title => mysite.it/immobili/view/villa-alessandro the Partial Template NOT works.

enter image description here

0

Try the condicional Tags.

the first one: {if segment_1 =="blog" && segment_2 =="view" && segment_3 ==""}

will display only the entries from blog channel : mysite.it/blog/view/

the second one: {if:elseif segment_1 =="blog" && segment_2 == "view" && segment_3 !="" && segment_4 ==""}

will display only the hello_world entry : mysite.it/blog/view/hello_world

As the view segment from your site seems not to be a template, is not processed by EpressionEngine I guess.

{if segment_2 =="blog" && segment_3 ==""}

    {exp:channel:entries channel='{ch}' limit='1' require_entry='yes'}
            .............. will display only: mysite.it/blog/view/ entries or others data
     {/exp:channel:entries}


{if:elseif segment_2 =="blog" && segment_3 == "view" && segment_4 =="" }

{exp:channel:entries channel='{ch}' limit='1' require_entry='yes'}

        ......... will display: mysite.it/blog/view/hello_world entries

{/exp:channel:entries}


    {/if}
0

mysite.it/blog/all Which shows all the articles But it does not work for mysite.it/blog/view/hello_world showing the article

mysite.it/blog/view/hello_world works fine because the segment_1: blog is an EE template group. The related entries content will be displayed.

mysite.it/blog/view/hello_world doesn't work because segment_2: view is not a template group, is not processed, so 404 error message.

I'm using conditional tags to solve this URL problem, it's working fine.

Templates routes could help you too, less verbose that many conditional tags:

https://docs.expressionengine.com/latest/cp/design/routes.html https://docs.expressionengine.com/latest/urls/template_routes.html .

If the segment_2 (view) and you want to associate it with an entry, is not a EE template groups you could use the conditional tags:

{if segment_1 =="blog" && segment_2 =="view" && segment_3 !=""}

If this condition is false, the second will be called:

 {if:elseif segment_1 == "blog"  && segment_2 !="" && segment_3 =="" }

you can use too:

 {if:elseif segment_1 == "blog"  && segment_2 =="all" && segment_3 ==""}

The template code:

{if segment_1 =="blog" && segment_2 =="view" && segment_3 !=""}
        {exp:channel:entries channel="your_channel" url_title="{segment_x}"}
                ........
        {/exp:channel:entries}



{if:elseif segment_1 == "blog"  && segment_2 !="" && segment_3 =="" }
        {exp:channel:entries channel="you_channel" url_title="{segment_x}"}
                ........
        {/exp:channel:entries}

{/if}

If needed, you can associate the url_title, with one of the segment (segment_1, segment_2...). https://docs.expressionengine.com/latest/channel/channel_entries.html#url-title

  • Hello I'm trying to use conditional tags but I can not understand – Alessandro Jan 7 at 20:27
  • Tomorow I will send a template with condional tags linked to URL condiions. – Stéphane Jan 8 at 0:09
  • Add the template code inside the blog EE template group: blog/index.html – Stéphane Jan 9 at 22:40
  • Hello, I still do not understand how to do it. Sorry. Can we continue chatting or provide you with my skype or other for fast support? – Alessandro Jan 10 at 19:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.