2011-06-12, 10:27:48
Oleg06 Wrote:what code to embed in a news manager? http://testbed.cartocopia.com/news/?arti...48b965f950
I modified the news manager plugin to call this one. Here is the code I used:
Code:
/*******************************************************
* @function show_article
* param $id - unique article id
* param $excerpt - if TRUE, print only a short article summary
* @action prints the article with given id on theme/site page
*/
function show_article($id, $excerpt=FALSE) {
$file = ARTICLEDATA . $id . '.xml';
$data = getXML($file);
if (!empty($data)) {
$date = $data->date;
$title = stripslashes(htmlspecialchars_decode($data->title, ENT_QUOTES));
$content = stripslashes(htmlspecialchars_decode($data->content, ENT_QUOTES));
if ($excerpt && !empty($data->excerpt)) {
$content = '<p>' . stripslashes(htmlspecialchars_decode($data->excerpt, ENT_QUOTES)) . '</p>';
}
$url = get_page_url(TRUE);
$url .= preg_match('/\?/', $url) ? '&' : '?';
$url .= "article=$id";
?>
<div class="article">
<h3 class="article_title">
<a href="<?php echo $url; ?>"><?php echo $title; ?></a>
</h3>
<p class="article_date">Posted on: <?php echo $date; ?></p>
<div class="article_content"><?php echo $content; ?></div>
<?php
if ($excerpt && !empty($data->excerpt))
echo "<p class=\"article_link\"><a href=\"$url\">Read more</a></p>";
elseif (!$excerpt)
get_external_comments($id, $url, $title);
echo "<p class=\"article_meta\"><b>Permalink:</b> <a href=\"$url\">$url</a></p>";
?>
</div>
<?php
} else {
echo '<p>The requested article does not exist.</p>';
}
}
I added the get_external_comments line.
-Rob A>