ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Question on switch and conditional using custom field

June 07, 2011 5:48pm

Subscribe [2]
  • #1 / Jun 07, 2011 5:48pm

    brankin

    150 posts

    I’m not sure if this is related to parsing order or not, and if there is a way around it.

    My code is

    {exp:channel:entries channel="employees"}
    {if yard == "Fayetteville"}
                    <div class="grid_3 employee {switch='abr-alpha ||abr-omega'}">
                            <div class="abr-block">
                            {employee_photo}
                                <div class="module-title">
                                    <h2 class="title">{title}</h2>
                                </div>
                                <span><em>{position}
    
                                {yard}</em></span>
                                <ul class="list-type-none">
                                    <li>P: {phone1}</li>
                                    {if email1}
                                    <li>E: {email1}</li>
                                    {/if}
                                </ul>
                            </div>
                        </div><!-- end grid 3 -->
    {/if}
    {/exp:channel:entries}

    What I am trying to do is go through and pull only entries where the custom field “yard” is equal to “Fayetteville” (or whatever location), and then the switch class that is applied just ensures that the directory info is laid out correctly (built on 960gs).

    It seems like the switch is applied to all entries and then they are filtered by the conditional.

    Here are links to compare
    http://rmrnc.com/index.php/contact/directory (This one lines up correctly and has no conditional).
    http://rmrnc.com/index.php/contact/directory/rocky_mount (odd spacing)

    Suggestions?

    Thanks
    Bryan

  • #2 / Jun 08, 2011 6:17am

    John Henry Donovan

    12339 posts

    Hi Bryan,

    You could use the search parameter here

    Note: Only custom fields of the type “Text Input”, “Textarea”, and “Drop-down Lists” are searched with this parameter.

    {exp:channel:entries channel="employees" search:yard="Fayetteville"}
                    <div class="grid_3 employee {switch='abr-alpha ||abr-omega'}">
                            <div class="abr-block">
                            {employee_photo}
                                <div class="module-title">
                                    <h2 class="title">{title}</h2>
                                </div>
                                <span><em>{position}
    
                                {yard}</em></span>
                                <ul class="list-type-none">
                                    <li>P: {phone1}</li>
                                    {if email1}
                                    <li>E: {email1}</li>
                                    {/if}
                                </ul>
                            </div>
                        </div><!-- end grid 3 -->
    {/exp:channel:entries}

    Does that help?

  • #3 / Jun 08, 2011 10:46am

    brankin

    150 posts

    Beautiful. John that does help. Solved the problem. I was using a P&T Pill custom field, but I can give up back end beauty for front end.

    Thanks again,
    Bryan

  • #4 / Jun 09, 2011 2:43am

    John Henry Donovan

    12339 posts

    No problems. Feel free to start anew thread if you have any more questions

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases