Summary + Complete article

12 posts by 5 authors in: Forums > CMS Builder
Last Post: June 24, 2010   (RSS)

By svsanchez - May 21, 2010

Hello, I am new with CMS Builder but have been using AM2 for some time, and what I need CMS Builder to do is to display on the "LIST PAGE":

- 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?
Sven Sanchez

www.deguate.com

Re: [svsanchez] Summary + Complete article

By jarvis - May 21, 2010

Have you tried the code generator?

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

Hi svsanchez,

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
The first CMS Builder reference book is now available on-line!







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

Hi there.

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

Hello, I am still trying to get this to work. I was able to show the title, summary and link to the PDF download but I am still unable to show a small image.

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!
Sven Sanchez

www.deguate.com

Re: [svsanchez] Summary + Complete article

By Chris - June 23, 2010

Hi svsanchez,

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.
All the best,
Chris

Re: [svsanchez] Summary + Complete article

By Chris - June 23, 2010

Hi svsanchez,

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.
All the best,
Chris

Re: [chris] Summary + Complete article

By svsanchez - June 23, 2010

Hello Chris, the field for my image is "portada".
Sven Sanchez

www.deguate.com

Re: [svsanchez] Summary + Complete article

By Chris - June 24, 2010

Hi svsanchez,

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.
All the best,
Chris