bigb42
|
| Posted: 07/04/2003, 11:13 PM |
|
I want to use the grid to display news type articles. I want to display this on my main page but do not want to display the whole story but only a part of the story which has a link to the whole story.
I want to do this so I would not have to type the story twice, 1 for the short snippet and 1 for the main story.
Please help as this is critical to my project
|
|
|
 |
Bigb42
|
| Posted: 07/04/2003, 11:17 PM |
|
I use PHP and Mysql
|
|
|
 |
DaveRexel
|
| Posted: 07/05/2003, 12:35 AM |
|
::
Have you tried
substr -- Returns part of a string
|
|
|
 |
Steve
|
| Posted: 07/05/2003, 1:23 AM |
|
here what I use,
This was posted somewhere , not sure where quite a while ago.
In this example its set to sow 50 words from the main text, and then link to a page called news_detail.php with a "read more" link.
============================
// Break it after 50 words, add link to story
//
// Grid name: news
// Affected Field Name: story
// notes: Change "50" to whatever # you desire
// variables $test and $short_story should be changed
// to whatever you prefer
//
global $news;
$test = $news->story->GetValue();
$strArray = explode(" ", $test);
$numWords = count($strArray);
if ($numWords < 50)
{
}
else {
if ($numWords > 50)
{
$strArray = array_slice($strArray, 0, 50);
}
$short_story = implode(" ", $strArray);
$short_story = $short_story . "...  <a href='news_detail.php'>read
more <img src='images/more_arrow' border='0' width='8'
height='9'><br><br></a>";
$news->story->SetValue($short_story);
}
============================
to make the read more link, work to the correct news item, change the link to suit your news_id variable
<a href='news_detail.php&news_id=$fldnews_id'>
then it can be used in a portal like situation with each items read more link pointing to the correctly called details page.
|
|
|
 |
bigb42
|
| Posted: 07/05/2003, 8:24 PM |
|
which event do I put this code into?
|
|
|
 |
RipCurl
|
| Posted: 07/07/2003, 5:15 PM |
|
in the Before Show Event of your grid/record
$num_chars=300; // designates how many words will show up. Also wont cut words in half should 300 characters be met.
$space=" ";
if(strlen($fldxxxxx) > $num_chars ) {
$fldxxxxx = substr(trim($fldxxxxx),0,$num_chars);
$fldxxxxx = substr($fldxxxxx,0,strlen($fldxxxxx)-strpos(strrev($fldxxxxx),$space));
$fldxxxxx = $fldxxxxx.'...';
}
Replace $fldxxxxx with the "news" field you named in your grid/table/db
|
|
|
 |
bigb42
|
| Posted: 07/20/2003, 10:45 PM |
|
I have been trying the read more link to work in the sense that it uses the news_id paramater and passes it to the next page. Can you please help.
CCS/MYSQL/PHP
|
|
|
 |
|