How to remove “Read more” link, when field is empty

4 posts by 2 authors in: Forums > CMS Builder
Last Post: September 25, 2009   (RSS)

I have a homepage with news, where the editors write both a short summary end an article. But if it is a short article, they only write some text in the summary, that appears on the frontpage.

My problem is, that there is a “Read more” link attached to every summary, so people can go from the frontpage to the article’s page. But when there is no article, because the whole text is in the summary, I would like to have no “Read more” link.

How can this be done, so the “Read more” link only is visible, when there actually is an article, and so no “Read more” link is, when the article field is empty?

Re: [einslistir] How to remove “Read more” link, when field is empty

an if statement is one of the more powerful pieces of code.

You can use it so that if the article field is empty then it wont show your read more link.

The general layout for the code is:

In a single record viewer:

<?php if ($your_tableRecord['your_field']): ?> ...your code...
<?php endif ?>

Or in a multi record viewer:

<?php foreach ($your_tableRecords as $record): ?>
<?php if ($record['your_field']): ?> ...your code...
<?php endif ?>
<?php endforeach; ?>


See how that works...

Best,

Jerry Kornbluth
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Re: [einslistir] How to remove “Read more” link, when field is empty

Great,

Jerry
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php