NEWS- display first 50 words, how?

2 posts by 2 authors in: Forums > CMS Builder
Last Post: October 25, 2010   (RSS)

Hi there,

I was wondering if it's possible for me to generate a form which will show only first 50 words of a news entry (no images if any are included in the main article) as well as a link which basically says "find out more" and takes me to the main news section... This is the code which i currently have on my home page:

<?php


// load viewer library
$libraryPath = 'cmsAdmin/lib/viewer_functions.php';
$dirsToCheck = array('/homepages/45/d281998588/htdocs/casaroccapiccola/','','../','../../','../../../');
foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }

// load records
list($home_pageRecords, $home_pageMetaData) = getRecords(array(
'tableName' => 'home_page',
'where' => 'num=1',
'limit' => '1',
));
$home_pageRecord = @$home_pageRecords[0]; // get first record

// show error message if no matching record is found
if (!$home_pageRecord) {
header("HTTP/1.0 404 Not Found");
print "Record not found!";
exit;
}

?>

<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<?php echo $home_pageRecord['content'] ?>
<!-- /INSTRUCTIONS -->
</DIV>
</DIV>
</DIV>
<!--END HOME COL-->
<DIV id=home-col>
<!--END FEATURE WRAP-->
</DIV>
<!--END HOME COL-->
<DIV id=home-col class=last>
<DIV id=blog-entry-wrap>
<h3 class="style14"><img src="123_files/photos/latest.jpg" width="198" height="36"></h3>
<DIV class="style19" id=blog-entry>

<p align="justify"><!-- /STEP2: Display Records --><?php


// load viewer library
$libraryPath = 'cmsAdmin/lib/viewer_functions.php';
$dirsToCheck = array('/homepages/45/d281998588/htdocs/casaroccapiccola/','','../','../../','../../../');
foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }

// load records
list($newsRecords, $newsMetaData) = getRecords(array(
'tableName' => 'news',
'where' => 'num=5',
'limit' => '1',
));
$newsRecord = @$newsRecords[0]; // get first record

// show error message if no matching record is found
if (!$newsRecord) {
header("HTTP/1.0 404 Not Found");
print "Record not found!";
exit;
}

?>

<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
</p>
<p align="right">
<!-- INSTRUCTIONS -->
<!-- /INSTRUCTIONS -->
<!-- For date formatting codes see: http://www.php.net/date -->
<?php echo $newsRecord['content'] ?>
<?php if (!$newsRecord): ?>
No record found!
<?php endif ?>
</p>
<p align="right"><span class="style14"><a href="news.php"><img src="123_files/photos/findout.jpg" width="157" height="36" border="0"></a></span></p>
<H3 align="justify" class="textarea style28"><span class="style29"><img src="123_files/photos/featured.jpg" width="198" height="36"></span></H3>
<P align="justify" class="style28">&nbsp;</P>
<?php


// load viewer library
$libraryPath = 'cmsAdmin/lib/viewer_functions.php';
$dirsToCheck = array('/homepages/45/d281998588/htdocs/casaroccapiccola/','','../','../../','../../../');
foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }

// load records
list($home_pageRecords, $home_pageMetaData) = getRecords(array(
'tableName' => 'home_page',
'where' => 'num=2',
'limit' => '1',
));
$home_pageRecord = @$home_pageRecords[0]; // get first record

// show error message if no matching record is found
if (!$home_pageRecord) {
header("HTTP/1.0 404 Not Found");
print "Record not found!";
exit;
}

?>

<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<p>
<!-- INSTRUCTIONS -->
<!-- /INSTRUCTIONS -->
<?php echo $home_pageRecord['content'] ?></p>



many thanks for all the help!