We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Grid & HTML table if:else

How Do I?

andrew001's avatar
andrew001
136 posts
10 years ago
andrew001's avatar andrew001

Im curious the best what to handle an HTML table with the if:else conditional.

I’m using the Grid, with 17 elements.

I’m outputting this into an HTML table, but I need to some how run an if:else on it all. The products in the grid could be in the hundreds, however, there may be only 5-6 elements used at a time? make sense?

Here is my code.

{exp:channel:entries channel="myproducts" disable="pagination"}
<table>
    <thead>
        <tr>
            <th>Item Number</th>
            <th>Size</th>
            <th>Thickness</th>
            <th>Weight</th>
            <th>Quantity</th>
            {product_details}{if ...}<th>Color</th>{/if}{/product_details}
            <th>yuioyui</th>
            <th>yuioyui</th>
            <th>yuioyu</th>
            <th>dfgbfg</th>
            <th>ertg</th>
            <th>ghkui</th>
            <th>ghnfgh</th>
            <th>assgtn</th>
            <th>asdf vbn</th>
            <th>asdfasdf</th>
            <th>asdf</th>
        </tr>
    </thead>
    <tbody>{product_details}
        <tr>
            <td>{product_details:item_no}</td>
            <td>{product_details:size}</td>
            <td>{product_details:thickness}</td>
            <td>{product_details:weight}</td>
            <td>{product_details:quantity}</td>
            <td>{product_details:color}</td>
            <td>Content Goes Here</td>
            <td>Content Goes Here</td>
            <td>Content Goes Here</td>
            <td>Content Goes Here</td>
            <td>Content Goes Here</td>
            <td>Content Goes Here</td>
            <td>Content Goes Here</td>
            <td>Content Goes Here</td>
            <td>Content Goes Here</td>
            <td>Content Goes Here</td>
            <td>Content Goes Here</td>
        </tr>{/product_details}
    </tbody>
</table>
{/exp:channel:entries}

This would require an if statement on every row… i dont think that is right. and I cant move the “product_details” tag out.

The only element that is standard across all entries is the item number. Everything else is is different depending on the product…. however, not every element will be used. maybe 5-6 at most.

Or is this not the way do even do this?

       
andrew001's avatar
andrew001
136 posts
10 years ago
andrew001's avatar andrew001

is it possible to output the name of the field? Not the contents, but name?

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.