1

i simply cant make a simple switchee condition works...just to load template snippet, with different sizes/css. Help, please? (My first time with Switchee)

<!-- switchee via simple text field -->
{exp:switchee variable = "{portfolio_size}" parse="inward"}

{case value="small"}   
<!-- start small portfolio -->
        <section id="content">
        <div class="container">
                <div class="row">
                        <div class="span8">
                                <article>
                                <div class="top-wrapper">
                                        <!-- start flexslider -->
                                        <div class="flexslider port">
                                                <ul class="slides">
                                                {exp:channel:entries channel="portfolio" orderby="date" sort="desc" limt="1"}
                                                <!-- matrix field -->
                                                        {portfolio_images}
                                                        <li>
                                                        {exp:ce_img:single src="{portfolio_image}" width="612" height="408" crop="yes" alt="{portfolio_image_title}}
                                                        </li>
                                                        {/portfolio_images}
                                                {/exp:channel:entries} 
                                                </ul>
                                        </div>
                                        <!-- end flexslider -->
                                </div>
                                </article>
                        </div>

                        <div class="span4">
                                <aside class="right-sidebar">

                                <div class="widget">
                                        <div class="widget-title"><h5 class="widgetheading">Project informations:</h5></div>
                                        <ul class="folio-detail">
                                        {exp:channel:entries channel="portfolio" orderby="date" sort="desc" limt="1"}
                                                <li><label>Category:</label> &nbsp;{categories}{category_name}{/categories}</li>
                                                <li><label>Client:</label> &nbsp;{portfolio_client}</li>
                                                <li><label>Project Date:</label>&nbsp; {portfolio_date}</li>
                                                {if portfolio_url}
                                                <li><label>Project link:</label><a href="{portfolio_url}" target="_blank"> &nbsp;{portfolio_url}</a></li>
                                                {/if}
                                        {/exp:channel:entries} 
                                        </ul>
                                </div>
                                <div class="widget">
                                        <div class="widget-title"><h5 class="widgetheading">About this project</h5></div>
                                        {exp:channel:entries channel="portfolio" orderby="date" sort="desc" limt="1"}
                                        <p>{portfolio_texto}</p>
                                        {/exp:channel:entries}
                                </div>

                                </aside>
                        </div>
                </div>
        </div>
        </section>
        <!-- end small portfolio -->
        {/case}

    {case value="bigger"}

        <!-- start portfolio bigger -->
        <section id="content">
        <div class="container">
                <div class="row">
                        <div class="span12">
                                <article>
                                <div class="top-wrapper">

                                        <!-- início do  flexslider -->
                                        <div class="flexslider port" style="margin-bottom: 0px">
                                                <ul class="slides">
                                                <!-- matrix field -->
                                                {exp:channel:entries channel="portfolio" orderby="date" sort="desc" limt="1"}
                                                        {portfolio_images}
                                                        <li>
                                                        {exp:ce_img:single src="{portfolio_image}" width="932" height="621" crop="yes" alt="{portfolio_image_title}}
                                                        </li>
                                                        {/portfolio_images}
                                                {/exp:channel:entries} 
                                                </ul>
                                        </div>
                                        <!-- end flexslider -->
                                </div>

                                </article>
                        </div>

                        <div class="span4">
                                <aside class="right-sidebar">
                                <div class="widget">
                                        <div class="widget-title"><h5 class="thin">Project informations:</h5></div>
                                        <ul class="folio-detail">
                                        {exp:channel:entries channel="portfolio" orderby="date" sort="desc" limt="1"}
                                                <li><label>Category:</label> &nbsp;{categories}{category_name}{/categories}</li>
                                                <li><label>Client:</label> &nbsp;{portfolio_client}</li>
                                                <li><label>Project Date:</label>&nbsp; {portfolio_date}</li>
                                                {if portfolio_url}
                                                <li><label>Project link:</label><a href="{portfolio_url}" target="_blank"> &nbsp;{portfolio_url}</a></li>
                                                {/if}
                                        {/exp:channel:entries} 
                                        </ul>
                                </div>
                                </aside>
                        </div>

                        <div class="span8">
                    <aside class="right-sidebar">
                        <div class="widget">
                                        <div class="widget-title"><h5 class="thin"><strong>About this project</strong></h5></div>
                                        {exp:channel:entries channel="portfolio" orderby="date" sort="desc" limt="1"}
                                        <p>{portfolio_texto}</p>
                                        {/exp:channel:entries}
                        </div>
                        </div>
                        </aside>

                </div>
        </div>
        </section>
        <!-- end portfolio bigger -->
        {/case}

        {/exp:switchee}
  • If you simplify the example further and replace the snippet variables with just text for testing, does it work as expected (to test if installed)? – Romans-8---31-39 Aug 4 '13 at 16:27
  • Hi! Please, give us more details. – Robson Sobral Aug 4 '13 at 16:41
  • I have it a portfolio template, and i just wanna to select, via common text fieldtype (just for tests - the final version i think to use the P&T Switch for this) one or another type of portfolio gallery (horizontal, bigger / vertical, smaller). Well, see my full code: pastebin.com/VMMJZpFm – Criatoria Aug 4 '13 at 21:16
  • What do you have around the exp:switchee variable pair? – Robson Sobral Aug 4 '13 at 22:31
  • kill the spaces here: variable = "{portfolio_size}" make it variable="{portfolio_size}" – Stephen Callender Aug 5 '13 at 15:54
2

Fabio!

Your snippets will load any way. They are loaded before the parse of all modules. But this code should word as you're planing. The content of the unmatched snippets will be removed of your template.

Buuuuuuuuuuuuuuuut, from where are you calling the portfolio_size? Are you using a exp:channel:entries variable pair around the switchee? Because, the value of this variable needs to come from somewhere.

By the way, you have a missing quotation mark on your ce_img variables:

{exp:ce_img:single src="{portfolio_image}" width="932" height="621" crop="yes" alt="{portfolio_image_title}}

It should be:

{exp:ce_img:single src="{portfolio_image}" width="932" height="621" crop="yes" alt="{portfolio_image_title}"}
| improve this answer | |
  • Yep i saw this!!! – Criatoria Aug 6 '13 at 21:58
3

I suspect the variable portfolio_size is actually a custom field in your portfolio channel. So you just need to simplify a little, wrapping your entries loop around the switchee tag pair. So something like this is what you need:

{exp:channel:entries channel="portfolio" orderby="date" sort="desc" limt="1"}
    {exp:switchee parse="inward" variable="portfolio_size"}
        {case value="small"}
            <!-- start small portfolio -->
    <section id="content">
    <div class="container">
            <div class="row">
                    <div class="span8">
                            <article>
                            <div class="top-wrapper">
                                    <!-- start flexslider -->
                                    <div class="flexslider port">
                                            <ul class="slides">
                                            <!-- matrix field -->
                                                    {portfolio_images}
                                                    <li>
                                                    {exp:ce_img:single src="{portfolio_image}" width="612" height="408" crop="yes" alt="{portfolio_image_title}}
                                                    </li>
                                                    {/portfolio_images}
                                            </ul>
                                    </div>
                                    <!-- end flexslider -->
                            </div>
                            </article>
                    </div>

                    <div class="span4">
                            <aside class="right-sidebar">

                            <div class="widget">
                                    <div class="widget-title"><h5 class="widgetheading">Project informations:</h5></div>
                                    <ul class="folio-detail">
                                            <li><label>Category:</label> &nbsp;{categories}{category_name}{/categories}</li>
                                            <li><label>Client:</label> &nbsp;{portfolio_client}</li>
                                            <li><label>Project Date:</label>&nbsp; {portfolio_date}</li>
                                            {if portfolio_url}
                                            <li><label>Project link:</label><a href="{portfolio_url}" target="_blank"> &nbsp;{portfolio_url}</a></li>
                                            {/if}
                                    </ul>
                            </div>
                            <div class="widget">
                                    <div class="widget-title"><h5 class="widgetheading">About this project</h5></div>
                                    <p>{portfolio_texto}</p>
                            </div>

                            </aside>
                    </div>
            </div>
        </div>
        </section>
        <!-- end small portfolio -->
        {/case}
        {case value="bigger"}
            SAME IDEA AS SMALL - JUST PUT ALL YOUR BIGGER CASE MARKUP HERE
        {/case}
    {/exp:switchee}
{/exp:channel:entries}
| improve this answer | |

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.