CMS - listings - wanting to have a <li> item appear with custom link when checked

5 posts by 2 authors in: Forums > CMS Builder
Last Post: July 15, 2010   (RSS)

By meg - July 15, 2010

I'm using a listings manager to develop news listings on a website. One of the features offers users to click on "Read Article" and "Link to Publication." How I have it set up currently in the CMS is, first an option to check to make the button active by using a multi-checkbox within "list". Then I have a section for either uploading a pdf or inserting a URL in a textfield. (Attached images). What I'm having problems with is getting the links to display properly with these buttons.

If I insert the "display" information (within the section editor of the list multi-checkbox) a link as such:
<li><a href="<?php echo $record['link_to_publication'] ?>" target="_blank">Link to Publication</a></li>

And code in my php doc as such:
<?php echo join(', ', getListLabels('news_articles', 'add_link_to_publication_button', $record['add_link_to_publication_button'])); ?>

The link visually looks correct BUT does not work and only displays as the PHP "<?php echo $record['link_to_publication'] ?>" instead of the link.

BUT if I insert the "display" information (within the section editor of the list multi-checkbox) a link as such: Link to Publication

And code in my php doc as such:
<li><a href="<?php echo $record['link_to_publication'] ?>" target="_blank">?php echo join(', ', getListLabels('news_articles', 'add_link_to_publication_button', $record['add_link_to_publication_button'])); ?></a></li>

The link works and visually looks good UNLESS the link isn't checked at all, then is displays an empty <li> with a sliver of a background.

How should I resolve this?? Any suggestions? Ideally, the first option is a cleaner way of handling the problem, if only I could get the links to work. I suppose, in the meantime, I'm going to fuss with the CSS in the second option and see if I can create a work-around showing the empty <li>

I attached images of the section editor, a portion of the news article form that pertains to this question and an image of the final front-end view of the news listing, along with the current code used to generate that news article view (using the first version of the method mentioned above.)


<?php foreach ($news_articlesRecords as $record): ?>
<div class="flavor all <?php echo join(', ', getListLabels('news_articles', 'select_movie_category', $record['select_movie_category'])); ?>">
<div class="article-list">
<div class="read"><ul class="read">
<?php echo join(', ', getListLabels('news_articles', 'add_link_to_publication_button', $record['add_link_to_publication_button'])); ?>
<?php echo join(', ', getListLabels('news_articles', 'read', $record['read'])); ?>
<?php echo join(', ', getListLabels('news_articles', 'add_download_presskit_button', $record['add_download_presskit_button'])); ?>
<?php echo join(', ', getListLabels('news_articles', 'watch_trailer', $record['watch_trailer'])); ?>
<?php echo join(', ', getListLabels('news_articles', 'add_watch_trailer_button', $record['add_watch_trailer_button'])); ?>
</div>
<h1><?php echo $record['publication'] ?></h1>
<p class="detail2"> <?php echo $record['title'] ?><br />
<?php echo $record['article_title_optional_line_2'] ?><br />
<?php echo $record['article_title_optional_line_3'] ?></p>
<?php echo $record['article_text'] ?>
</div>
</div>
<?php endforeach ?>

Attachments:

1_001.jpg 162K

2_001.jpg 192K

3_001.jpg 87K

Re: [meg] CMS - listings - wanting to have a <li> item appear with custom link when checked

By meg - July 15, 2010

Ok...so I looked into things a little further....I have a feeling it has something to do with the more advanced options in the Section Editor under list, multi-value checkbox: either "Get Options from Database" or "Get Options from MYSQL query"

Am I on the right track? If so, how do I do this? I'm treading new ground on these advanced options.

Again...I just want this checkbox, when activated, to add a menu item as such:
<li><a href="<?php echo $record['link_to_publication'] ?>" target="_blank">Link to Publication</a></li>

And actually have the link work, instead of displaying <?php echo $record['link_to_publication'] ?> as the link.

Re: [meg] CMS - listings - wanting to have a <li> item appear with custom link when checked

By Jason - July 15, 2010

Hi meg,

It seems like the field 'add_link_to_publication_button' will only ever have 1 value, it may be better to set it up as a regular check box. That way, if it's checked, we'll output some code, otherwise, we wont.

Something like this:

<?php if($record['add_link_to_publication_button']): ?>
<li><a href="<?php echo $record['link_to_publication'];?>" target="_blank">Link to Publication</a></li>
<?php endif ?>


Hope this helps.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] CMS - listings - wanting to have a <li> item appear with custom link when checked

By meg - July 15, 2010

Exactly! Works like a charm. [:)]
Thank you so much!!