Summary + Complete article
12 posts by 5 authors in: Forums > CMS Builder
Last Post: June 24, 2010 (RSS)
By svsanchez - May 21, 2010
- Title of the article
- Summary of the article
- A small picture in case we upload one
- A link to the full article
How can I achieve this?
www.deguate.com
Re: [svsanchez] Summary + Complete article
By jarvis - May 21, 2010
Go to Admin > Code Generator > use the options and click 'Show Code' it will then produce the code for you with comments. Use your editor to then remove anything you don't want.
HTH
Re: [jarvis] Summary + Complete article
By gkornbluth - May 23, 2010
There are many ways to display what you’re looking for. You can also use something like the maxwords function to display your article summary.
Here’s one approach based on information in my CMSB Cookbook http://www.thecmsbcookbook.com
In the head of your page insert the following code: (straight out of the code generator)
<?php
require_once "/your_path_to/cmsAdmin/lib/viewer_functions.php";
list($your_tableRecords, $your_tableMetaData) = getRecords(array(
'tableName' => 'your_table',
));
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
In the body of your page, before you display your information, put the following code to set up the maxwords function:
<?PHP
function maxWords($textOrHtml, $maxWords) {
$text = strip_tags($textOrHtml);
$words = preg_split("/\s+/", $text, $maxWords+1);
if (count($words) > $maxWords) { unset($words[$maxWords]); }
$output = join(' ', $words);
return $output;
}
?>
Then, where you want to display your articles and pictures, use something like this:
strupper forces the title to be displayed in CAPS, the number in the <?PHP echo maxWords($record['full_article'], 40); line sets the number of words to display before the ... (read more).
<?php foreach ($your_tableRecords as $record): ?>
<?php foreach ($record['your_image'] as $upload): ?>
<a href="http://www.your_site.com/your_detail_page.php?<?php echo $record['num'] ?>"><br /><br /><img border="0" src="<?php echo $upload['thumbUrlPath'] ?>" alt="" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" align="center" /></a>
<?php endforeach ?>
</td>
<td align="left" valign="top"><div><a href="http://www.your_site.com/your_detail_page.php?<?php echo $record['num'] ?>"><?php $event_title = ($record['title']); ?><?php echo strtoupper($title); ?></a></div>
<br />
<?PHP echo maxWords($record['full_article'], 40);
?>...<a href="http://www.your_site.com/your_detail_page.php<?php echo $record['num'] ?>">(Read More)</a>
<?php endforeach; ?>
</td>
</tr>
</table>
Styling is of course up to you.
Hope that gives you some ideas.
Best,
Jerry Kornbluth
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php
Re: [svsanchez] Summary + Complete article
By ross - May 25, 2010
Thanks for posting!
I think the best place to start is more along the lines of what jarvis was saying. If you go to the Code Generator and get it to give you the code for a list page. Leave everything else default for now so you can get the hang of things.
Just copy all the code into a new page like "listPageDemo.php" and work with that. It's a really simple page to start with but it will show you how everything hooks in.
Give it a shot and let us know how you make out :).
Thanks!
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com
Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/
Re: [ross] Summary + Complete article
By svsanchez - June 23, 2010
I created a field as "upload" on the CMS called "portada" and what I would like is to show the image I upload with the summary without having to paste it on the summary itself.
How can I do this?
You can see the page (without the small images) here:
http://www.observatoriodsan.org/gestiondeconocimiento.php
Thank you!
www.deguate.com
Re: [svsanchez] Summary + Complete article
By Chris - June 23, 2010
Looking at your source, I can see:
<img src="
Notice: Undefined variable: upload in /home/observat/public_html/gestiondeconocimiento.php on line 89
" alt="" />
Can you please post the complete PHP source code for your page? We'll be able to sort it out for you.
Chris
Re: [chris] Summary + Complete article
By svsanchez - June 23, 2010
<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php
// load viewer library
$libraryPath = 'cmsAdmin/lib/viewer_functions.php';
$dirsToCheck = array('/home/observat/public_html/','','../','../../','../../../');
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($gestion_del_conocimientoRecords, $gestion_del_conocimientoMetaData) = getRecords(array(
'tableName' => 'gestion_del_conocimiento',
'perPage' => '10',
'allowSearch' => '0',
));
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Gestion del Conocimiento</title>
<style type="text/css">
body { font-family: arial; }
.instructions { border: 3px solid #000; background-color: #EEE; padding: 10px; text-align: left; margin: 25px}
</style>
</head>
<body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0" bgcolor="#E1E7C3">
<div align="center">
<table border="0" width="1000" id="table1" cellspacing="0" cellpadding="0">
<tr>
<td>
<div align="center">
<?php include('aaa-header.htm'); ?>
</div>
</td>
</tr>
</table>
</div>
<div align="center">
<table border="0" width="1000" id="table2" cellspacing="0" cellpadding="0">
<tr>
<td width="205" valign="top" align="center" bgcolor="#FFFFFF">
<?php include('aaa-menu.htm'); ?>
</td>
<td align="center" valign="top" bgcolor="#FFFFFF" width="595">
<table border="0" cellpadding="5" cellspacing="0" width="100%" id="table5">
<tr>
<td align="left" valign="top">
<br>
<!-- CONTENIDO -->
<!-- STEP2: Display Records (Paste this where you want your records to be listed) -->
<h1><font size="5" color="#3366CC">Gestión del conocimiento</font></h1>
<font size="2">
<?php foreach ($gestion_del_conocimientoRecords as $record): ?>
<b><?php echo $record['title'] ?></b><br/>
Publicado el: <?php echo date("D, M jS, Y g:i:s a", strtotime($record['date'])) ?><br/>
<!-- For date formatting codes see: http://www.php.net/date -->
<img src="<?php echo $upload['urlPath'] ?>" alt="" />
<?php echo $record['content'] ?><!-- STEP 2a: Display Uploads for field 'documento' (Paste this anywhere inside STEP2 to display uploads) --><!-- Upload Fields: num, createdTime, tableName, fieldName, recordNum, preSaveTempId, filePath, filename, extension, thumbFilePath, isImage, hasThumbnail, urlPath, width, height, thumbUrlPath, thumbWidth, thumbHeight, info1, info2, info3, info4, info5 --><?php foreach ($record['documento'] as $upload): ?>
<?php if ($upload['hasThumbnail']): ?>
<img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" /><br/>
<?php elseif ($upload['isImage']): ?>
<img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" /><br/>
<?php else: ?>
<P><img border="0" src="images/download15x15.jpg" width="15" height="15">Descargar:
<a href="<?php echo $upload['urlPath'] ?>"> <?php echo $upload['filename'] ?></a><br/>
<?php endif ?>
<?php endforeach ?>
<!-- STEP2a: /Display Uploads -->
</font>
<hr/>
<font size="2">
<?php endforeach ?>
<?php if ($gestion_del_conocimientoMetaData['invalidPageNum']): ?>
Results page '<?php echo $gestion_del_conocimientoMetaData['page']?>'
not found, <a href="<?php echo $gestion_del_conocimientoMetaData['firstPageLink'] ?>">
start over >></a>.<br/><br/>
<?php elseif (!$gestion_del_conocimientoRecords): ?>
No records were found!<br/><br/>
<?php endif ?>
<!-- /STEP2: Display Records -->
<!-- STEP3: Display Page Links (Paste anywhere below "Load Record List") -->
<?php if ($gestion_del_conocimientoMetaData['prevPage']): ?>
<a href="<?php echo $gestion_del_conocimientoMetaData['prevPageLink'] ?>">
<< previo</a>
<?php else: ?>
<< previo
<?php endif ?>
- página <?php echo $gestion_del_conocimientoMetaData['page'] ?>
de <?php echo $gestion_del_conocimientoMetaData['totalPages'] ?>
-
<?php if ($gestion_del_conocimientoMetaData['nextPage']): ?>
<a href="<?php echo $gestion_del_conocimientoMetaData['nextPageLink'] ?>">
siguiente >></a>
<?php else: ?>
siguiente >>
<?php endif ?>
<!-- /STEP3: Display Page Links -->
<!-- /CONTENIDO -->
</font>
</td>
</tr>
</table>
<p align="left">
</td>
<td width="200" bgcolor="#BFC898" valign="top" align="center">
<p>
<?php include('aaa-lateral.htm'); ?> </td>
</tr>
</table>
</div>
<div align="center">
<table border="0" cellpadding="0" cellspacing="0" width="1000" id="table6" bgcolor="#FFFFFF">
<tr>
<td>
<p align="center">
<?php include('aaa-footer.htm'); ?></td>
</tr>
</table>
</div>
</body>
</html>
www.deguate.com
Re: [svsanchez] Summary + Complete article
By Chris - June 23, 2010
You have some code in your page which references $upload before the Foreach that makes $upload available:
<img src="<?php echo $upload['urlPath'] ?>" alt="" />
...
<?php foreach ($record['documento'] as $upload): ?>
You'll need to remove the line in red.
Is "documento" the name of the upload field which has an image? The code in your foreach looks good.
Chris
Re: [chris] Summary + Complete article
By svsanchez - June 23, 2010
www.deguate.com
Re: [svsanchez] Summary + Complete article
By Chris - June 24, 2010
Try changing this:
<?php foreach ($record['documento'] as $upload): ?>
...to this:
<?php foreach ($record['portada'] as $upload): ?>
Does that help? Please let me know if you have any questions.
Chris