Another question: Item display only if data present?
3 posts by 2 authors in: Forums > CMS Builder
Last Post: March 15, 2009 (RSS)
By Bassman - March 15, 2009
I have another question:
Because we have so many different kinds of product, there would be some items we sell that would have different kinds of specification to others. Is there any way of making the output show only fields that have data inputted for them?
For example: Say we have Product A. & Product B.
Product A is electrically powered, while product B is air-powered. For both Product A and Product B, we would need fields for weight and dimensions, and for a description, but only product A would require a field for voltage and only B would require a field for air pressure. But we would not want a Voltage field to display for an air-powered product, and vice versa.
So, if entering data for Product A, the Air Pressure field is left blank (not filled out in the input form) and when the product page is viewed, the Air Pressure field is not even shown.
I hope this is clear :)
Because we have so many different kinds of product, there would be some items we sell that would have different kinds of specification to others. Is there any way of making the output show only fields that have data inputted for them?
For example: Say we have Product A. & Product B.
Product A is electrically powered, while product B is air-powered. For both Product A and Product B, we would need fields for weight and dimensions, and for a description, but only product A would require a field for voltage and only B would require a field for air pressure. But we would not want a Voltage field to display for an air-powered product, and vice versa.
So, if entering data for Product A, the Air Pressure field is left blank (not filled out in the input form) and when the product page is viewed, the Air Pressure field is not even shown.
I hope this is clear :)
Re: [Bassman] Another question: Item display only if data present?
By zip222 - March 15, 2009
This just requires some fairly simple php...
<?php if ($record['weight']): ?>
<p>Any html placed here would only be displayed if the "weight" field contains data. </p>
<p>If its blank, none of this will be displayed.</p>
<p>You can also include PHP, such as <?php echo ($record['weight']) ?></p>
<?php endif ?>
Re: [jdancisin] Another question: Item display only if data present?
By Bassman - March 15, 2009
Wow, thank you! Not only answered, but a solution!