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.

Conditional?

September 27, 2012 4:55am

Subscribe [2]
  • #1 / Sep 27, 2012 4:55am

    Sean Ford

    13 posts

    I am using a toggle content accordion.  I have it set up using a matrix.  I want the first toggle container to have the products description in it, but it doesn’t work if I just add the tag {product_description} in the matrix.  Is there a conditional I can use that will fill in the first container with it? 
    This is my code:

    {exp:channel:entries channel="products" dynamic="yes" limit="1"}
       <div class="cont-left" id="content">
        <h3>Product Details</h3>
    <p>     <div class="toggle-container"><br />
          {accordion}<br />
           <div class="toggle-header"><br />
            </p><h4><a href="#class=tog-open"><span></span>{panel_title}</a></h4><p>   <br />
            <div class="clear"></div>     <br />
           </div><br />
           <div class="toggle-content"><br />
            {panel_content}<br />
           </div><br />
          {/accordion}<br />
         </div> <br />
        <br />
      {/exp:channel:entries}

  • #2 / Sep 27, 2012 4:38pm

    Kevin Smith

    4784 posts

    Hi Sean,

    I’m not sure I know enough about your setup just yet to help here. Could you let me know the fieldtypes of the fields you’re displaying or want to display? Also, are you using a jQuery plugin to set up this accordion? Knowing the other components that are in play here will give me the context I need to help.

    Thanks!

  • #3 / Sep 28, 2012 5:53am

    Sean Ford

    13 posts

    No problem.  I’ve attached a couple of images to show you what I mean.  The first image is how I have the accordion set up in EE (using matrix+text+wygwam).  The second image is the accordion displayed on the website.  What I am trying to do is have the first accordion toggle container display the {product_description} field, because on a previous page I have the {product_description} being trunchtml’d. 

    http://grab.by/gogk
    http://grab.by/gogo

  • #4 / Sep 28, 2012 3:46pm

    Kevin Smith

    4784 posts

    Ok, I see now. Looking at what you have here, it looks to me like it should work. Since this is a Pixel & Tonic add-on, however, they’d be the ones to get official support with it. Have you checked with them to see what’s going on?

  • #5 / Sep 28, 2012 3:47pm

    Sean Ford

    13 posts

    Nopes! I was hoping there would be some conditional for it, so I came here first.

  • #6 / Sep 28, 2012 4:07pm

    Kevin Smith

    4784 posts

    I think I might be confused here. What kind of fieldtype is {product_description}? Is that not part of the matrix field?

  • #7 / Sep 28, 2012 4:40pm

    Sean Ford

    13 posts

    No, {product_description} is another channel field.  It’s a textarea.

  • #8 / Oct 01, 2012 2:44pm

    Dan Decker

    7338 posts

    Hi Sean,

    Dan here, I’d like to pop in to help too.

    Can we see the full template and any JavaScript you’re using?

    I’m not clear on where {product_description} needs to factor into your goal on how you want it to react with the accordion.

    ~

  • #9 / Oct 01, 2012 6:47pm

    Sean Ford

    13 posts

    Look at that second screenshot I posted above.  Those are the containers of the Accordion.  On the first container I want it to display the content for {product_description}

  • #10 / Oct 03, 2012 2:50pm

    Dan Decker

    7338 posts

    Hey Sean,

    If I follow, you need to operate on the Matrix row count variable:

    {exp:channel:entries channel="products" dynamic="yes" limit="1"}
       <div class="cont-left" id="content">
        <h3>Product Details</h3>
    <p>     <div class="toggle-container"><br />
          {accordion}<br />
    {if row_count == 1}{product_description}{/if}<br />
           <div class="toggle-header"><br />
            </p><h4><a href="#class=tog-open"><span></span>{panel_title}</a></h4><p>   <br />
            <div class="clear"></div>     <br />
           </div><br />
           <div class="toggle-content"><br />
            {panel_content}<br />
           </div><br />
          {/accordion}<br />
         </div>     <br />
      {/exp:channel:entries}

    You’ll want to place that conditional where you want {product_description} to display. If you want it outside the Matrix field tag pair, use ExpressionEngine’s {count} variable instead.

    Does that help?

    Cheers,

  • #11 / Oct 03, 2012 2:57pm

    Sean Ford

    13 posts

    Dan you’re the man!  Thanks, that worked!

  • #12 / Oct 04, 2012 12:22pm

    Dan Decker

    7338 posts

    Hey Sean!

    Awesome! My pleasure to help.

    If you need anything else, please let us know.

    Cheers!

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

ExpressionEngine News!

#eecms, #events, #releases