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.

Entries Tag - Working with Tables

June 22, 2012 6:44pm

Subscribe [2]
  • #1 / Jun 22, 2012 6:44pm

    Hello All,

    I’m working with the Entries tag, and would like it to display 3 cells per row. I currently have the following code, and can’t seem to figure out how to make the code be “smart enough” to know when 3 cells are displayed stop the tag and go to a new row… is this possible?

    <table width="670" border="0">
      <tr>
    {exp:channel:entries channel="media_video" orderby="date" sort="asc"}
    <td width="225px">
    
     <a href="http://{url_title_path=%27media/video%27}" class="video">_  [url=http://media.amityboattours.com/video/{if]http://media.amityboattours.com/video/{if</a> video_hd ==
     [/url]
     
    
    
     <a href="http://{url_title_path=%27media/video%27}" class="video">_ <strong>{title}</strong>_ </a>  
    
     
    
     <a href="http://{path=/contribute/{url_title}}">Comments ({comment_total})</a> {if video_exclusive =="Yes"} | Exclusive Video{/if}
    </td>
    {/exp:channel:entries}
      </tr>
    </table>
  • #2 / Jun 22, 2012 7:26pm

    R.K.Foster

    138 posts

    You can do this with the “count” variable something like this…

    {if count == 3}
    </td></tr>
    <tr><td>
    {/if}

    That’s just the general idea, I didn’t look too closely at your example. “count” is increased for each entry found by the channel tag.

    - Bob.

  • #3 / Jun 22, 2012 7:32pm

    R.K.Foster

    138 posts

    Moving the “tr” inside the channel:entries tag will give you one row for each entry in your channel…

    <table width="670" border="0">
    {exp:channel:entries channel="media_video" orderby="date" sort="asc"}
      <tr>
    <td width="225px">
    
     <a href="http://{url_title_path=%27media/video%27}" class="video">_  [url=http://media.amityboattours.com/video/{if]http://media.amityboattours.com/video/{if</a> video_hd ==
     [/url]
     
    
    
     <a href="http://{url_title_path=%27media/video%27}" class="video">_ <strong>{title}</strong>_ </a>  
    
     
    
     <a href="http://{path=/contribute/{url_title}}">Comments ({comment_total})</a> {if video_exclusive =="Yes"} | Exclusive Video{/if}
    </td>
      </tr>
    {/exp:channel:entries}
    </table>

    Was that what you wanted to do?

    - Bob

  • #4 / Jun 22, 2012 7:33pm

    For some reason now it’s only showing one of the posts at a time… I’m new to this so would you be able to help me piece this together?

  • #5 / Jun 22, 2012 7:45pm

    R.K.Foster

    138 posts

    Make sure you set the “dynamic” parameter for what you want. If dynamic is set to “yes” it will only display entries based on the url_title in the page url. If you have it set to “no” then it will list all entries without regard to what page you’re on. I think the default is “yes” for the dynamic parameter. Check the dynamic parameter in the User Guide if you need a better explanation.

    - Bob.

    {exp:channel:entries channel="media_video" orderby="date" sort="asc" dynamic="no"}
  • #6 / Jun 23, 2012 10:01am

    No, I want it to be 3 across and as many down as necessary… I just need it to auto generate the </td> after the third entry

  • #7 / Jun 23, 2012 10:05am

    I figured it out, after the entire code, I added:

    {if count >= 3}
    </tr>
    {/if}

  • #8 / Jun 23, 2012 6:37pm

    Alright, I take that back, it worked now for the first row of the table.

    To be clear, what I’m trying to accomplish is having a table split into three cells (each entry per 1 cell), each row will have 3 cells, so on and so forth.

    Here’s the code:

    <h2>Video Gallery</h2><p><a href="http://{url_title_path=%27media/video%27}%22name=%22video%22&gt&lt/a&gt&lttable" class="video">_  [url=http://site/video/{if]http://site/video/{if</a> video_hd ==<br />
     [/url]<br />
     </p>
    
    <p><br />
     <a href="http://{url_title_path=%27media/video%27}" class="video">_ <strong>{title}</strong>_ </a>  </p>
    
    <p> </p>
    
    <p> <a href="http://{path=/contribute/{url_title}}">Comments ({comment_total})</a> {if video_exclusive =="Yes"} | Exclusive Video{/if}<br />
    </td></p>
    
    <p>{if count >= 3}<br />
    </tr><br />
    {/if} </p>
    
    <p>{/exp:channel:entries}<br />
      </tr><br />
    </table>

    The first three entries are working perfectly, then when the fourth on is added it just keeps adding the </tr> from the conditional. Help! 😊

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

ExpressionEngine News!

#eecms, #events, #releases