ff123 wrote:Hi,
I am using the reptags {teaser_ex} and {show_content:xxx}.
Now I want to show a news archive with {teaser_ex}. So {teaser_ex} shows the news items, but only the summary of the articles.
Now I want to show certain news items on the front page. So I use {show_content:xxx}. But {show_content:xxx} shows the ful article not the summary.
My problem is that I have to enter the news twice: in the summary for {teaser_ex} and in the full article for {show_content:xxx}. My client won't like this.
Does anyone have a suggestion how to solve this?
you want to show the summary text and an particular contentpart below the summary?
if so, try this modified version:
Code: Select all
<?php
//----------------------------------------------------------------------------------------------
// {SHOW_CONTENT}
// AUTHOR: Jens Zetterström
// DESCRIPTION: Shows the content of the article content part with the specified id.
// INSTALLATION: Put the code in frontend_render (for example in a file called show_content.php)
// Note: If the article content part contains replacement tags (for example {SITE}),
// they will not be replaced because code in frontend_render is executed after those
// replacement tags already have been processed. To fix, put the code in
// content.article.inc.php instead.
// {SHOW_CONTENT:acontent_id:show_summary}
// where acontent_id is the id of the content part.
// and set show_summary to 1 if you want to show the summary, 0 to hide it -> added by Erich Munz, erich_k4
//----------------------------------------------------------------------------------------------
function show_content($id, $showsummary, $db)
{
$CNT_TMP = '';
$template_default = $GLOBALS["template_default"];
$sql = "SELECT * " .
"FROM " . DB_PREPEND . "phpwcms_articlecontent " .
"INNER JOIN " . DB_PREPEND . "phpwcms_article ON " . DB_PREPEND . "phpwcms_article.article_id = " . DB_PREPEND . "phpwcms_articlecontent.acontent_aid " .
"WHERE acontent_id = " . $id . " " .
"AND acontent_visible = 1 " .
"AND acontent_trash = 0 " .
"AND " . DB_PREPEND . "phpwcms_article.article_deleted=0 AND ".DB_PREPEND."phpwcms_article.article_begin < NOW() " .
"AND " . DB_PREPEND . "phpwcms_article.article_end > NOW() ";
"ORDER BY acontent_sorting, acontent_id;";
if($cresult = mysql_query($sql, $db) or die("error retrieving article from database"))
{
if($crow = mysql_fetch_array($cresult))
{
if ($showsummary == 1) $CNT_TMP .= '<div class="articleSummary">'.$crow["article_summary"].'</div>'; // -> added by Erich Munz, erich_k4
// Space before
if($crow["acontent_before"])
{
$CNT_TMP .= '<div style="margin:' . $crow["acontent_before"] . 'px 0 0 0; padding:0 0 0 0; clear:both;"></div>';
}
// include content part code section
include("include/inc_front/content/cnt" . $crow["acontent_type"] . ".article.inc.php");
//check if top link should be shown
if($crow["acontent_top"])
{
if($template_default["article"]["top_sign_before"].$template_default["article"]["top_sign_after"])
{
$CNT_TMP .= $template_default["article"]["top_sign_before"];
$CNT_TMP .= '<a href="#top">'.$template_default["article"]["top_sign"].'</a>';
$CNT_TMP .= $template_default["article"]["top_sign_after"];
}
else
{
$CNT_TMP .= '<br /><a href="#top">' . $template_default["article"]["top_sign"] . '</a>';
}
}
// Space after
if($crow["acontent_after"])
{
$CNT_TMP .= '<div style="margin:0 0 ' . $crow["acontent_after"] . 'px 0; padding:0 0 0 0; clear:both;"></div>';
}
}
}
return $CNT_TMP;
}
if( ! ( strpos($content["all"],'{SHOW_CONTENT:')===false ) )
{
$content["all"] = preg_replace('/\{SHOW_CONTENT:(.*?):(.*?)\}/ie', 'show_content("$1", "$2", $db);', $content["all"]);
}
?>
USAGE:
{SHOW_CONTENT:acontent_id:show_summary}
where acontent_id is the id of the content part.
and set show_summary to 1 if you want to show the summary, 0 to hide it
NOTE that this modified version only displays the htmlformatted summary text, without images or assigned templatesettings...