Modifying design based upon what's seen in list pages
2 posts by 2 authors in: Forums > CMS Builder
Last Post: April 20, 2011 (RSS)
By (Deleted User) - April 19, 2011
I have a list page that shows the complete address of each list item such as
<div><?php echo $record['city'] ?>, <?php echo $record['state_province'] ?> <?php echo $record['postcode'] ?> <?php echo $record['country'] ?></div>
But, not every record shows all of these details.
So where one record might say
Beverly Hills, CA 90210 United Sates
another listing might just read
United States
How can I get the comma, spacing etc that I've created in the design to not appear if all of the details do not appear.
Thank you!
<div><?php echo $record['city'] ?>, <?php echo $record['state_province'] ?> <?php echo $record['postcode'] ?> <?php echo $record['country'] ?></div>
But, not every record shows all of these details.
So where one record might say
Beverly Hills, CA 90210 United Sates
another listing might just read
United States
How can I get the comma, spacing etc that I've created in the design to not appear if all of the details do not appear.
Thank you!
Re: [kimamel] Modifying design based upon what's seen in list pages
By Kenny - April 20, 2011
You will need to use "if statements"
On a Detail Page:
<?php if ($your_tableRecord['your_field']): ?>
...your code...
<?php endif ?>
On a List Page:
<?php foreach ($your_tableRecords as $record): ?>
<?php if ($record['your_field']): ?>
...your code...
<?php endif ?>
<?php endforeach; ?>
This way, you are checking to see if the content is there, and if it is, then display the code between the if and endif
Let us know if you need further help on this.
Kenny
On a Detail Page:
<?php if ($your_tableRecord['your_field']): ?>
...your code...
<?php endif ?>
On a List Page:
<?php foreach ($your_tableRecords as $record): ?>
<?php if ($record['your_field']): ?>
...your code...
<?php endif ?>
<?php endforeach; ?>
This way, you are checking to see if the content is there, and if it is, then display the code between the if and endif
Let us know if you need further help on this.
Kenny