getting a single news item to show.

4 posts by 3 authors in: Forums > CMS Builder
Last Post: May 27, 2010   (RSS)

By (Deleted User) - May 27, 2010 - edited: June 7, 2010

hi. I have set up a multi list page (labeled news.php) and set up a page detail as newsDetail.php -- I'm having a problem with two things.

1) on the news.php page.. any way to change the link i.e. newsDetail.php?news-headline-to-come-here-4 to something else like... click here for more info?

2) on the detail page --- any way to show one news item instead of all of them????

THANKS! I'm loving this tool!

-CF

Re: [cfdesign] getting a single news item to show.

By Jason - May 27, 2010

Hi,

For your first question, you just need to replace what appears between the <a></a> tags. Right now, you have this:
<a href="<?php echo $record['_link'] ?>"><?php echo $record['_link'] ?></a><br/>

You need to replace it with this:
<a href="<?php echo $record['_link'] ?>">*YOUR TEXT HERE*</a><br/>

You just need to replace "*YOUR TEXT HERE*" with whatever text you want displayed as a link.

We need to make a few more changes to newsDetail.php.

First, we need to restrict the number of records being returned to only return 1. Replace your current getRecords statement with this:


// load records
list($newsRecords, $newsMetaData) = getRecords(array(
'tableName' => 'news',
'where' => whereRecordNumberInUrl(1),
'limit' => 1,
));


This will only return one record. Now we need to select that record. Put this code right below:

$newsRecord=$newsRecords[0]; //select the first record.


Last thing we need to do is change the code where we're outputting our content. Replace all the code in "STEP 2" with this:


<!-- STEP2: Display Records (Paste this where you want your records to be listed) -->
<?php echo date("D, M jS, Y g:i:s a", strtotime($newsRecord['date'])) ?><br/>
<!-- For date formatting codes see: http://www.php.net/date -->
<span class="headline"><?php echo $newsRecord['title'] ?></span><br/>
<?php echo $newsRecord['content'] ?><br/>
<hr/>

<?php if (!$newsRecords): ?>
No records were found!<br/><br/>
<?php endif ?>
<!-- /STEP2: Display Records -->&nbsp;</p></td>


Give this a try and let me know if you run into any issues.
---------------------------------------------------
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] getting a single news item to show.

By (Deleted User) - May 27, 2010

PERFECT! Thanks That did the trick!!!! I appreciate your help!