lundi 24 décembre 2018

Can I display different parts of singular view based on the URL?

For simplicity's sake, imagine I have a view that contains an ul and 4 divs

<ul>
    <li>Section 1</li>
    <li>Section 2</li>
    <li>Section 3</li>
    <li>Section 3</li>
<ul>

<div class='1'></div>

<div class='2'></div>

<div class='3'></div>

<div class='4'></div>

Is it possible to make it so that depending on the URL, the user sees one of the four divs only? For example:

On URL www.example.com/first the user receives a view containing:

<ul>
    <li>Section 1</li>
    <li>Section 2</li>
    <li>Section 3</li>
    <li>Section 3</li>
<ul>

<div class='1'></div>

On URL www.example.com/second the user receives a view containing:

<ul>
    <li>Section 1</li>
    <li>Section 2</li>
    <li>Section 3</li>
    <li>Section 3</li>
<ul>

<div class='2'></div>

On URL www.example.com/third the user receives a view containing:

<ul>
    <li>Section 1</li>
    <li>Section 2</li>
    <li>Section 3</li>
    <li>Section 3</li>
<ul>

<div class='3'></div>

I could easily do that if I have 4 different views, but my goal is to have all the code in 1 view and then based on the URL to present the correct section.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire