2011-08-24, 22:05:52
hi there.
i use the excerpt function to shorten news on the overview page. i now want to add a link which links to the full version (as the headline already does). Something like a linked [read more] instead of just [...] plain text
i tried something by adding the following in the function nm_show_post (site.php)
this causes the correctly linked text under every news excerpt, but also at the end of every news itself.
i then tried to add some code in the function nm_create_excerpt (functions.php)
this adds the link ".../index.php?id=blog&post="
but the last part of the url is missing.
Could somebody help me with this? Thanks in advance
i use the excerpt function to shorten news on the overview page. i now want to add a link which links to the full version (as the headline already does). Something like a linked [read more] instead of just [...] plain text
i tried something by adding the following in the function nm_show_post (site.php)
Code:
...
<div class="nm_post_content"><?php echo $content; ?></div>
<?php
echo '<a href="';
echo $url;
echo '">read more</a>';
# print tags, if any
if (!empty($post->tags)) {
...
this causes the correctly linked text under every news excerpt, but also at the end of every news itself.
i then tried to add some code in the function nm_create_excerpt (functions.php)
Code:
/*******************************************************
* @function nm_create_excerpt
* @param $content the post content
* @return a truncated version of the post content
*/
function nm_create_excerpt($content) {
global $NMEXCERPTLENGTH;
$len = intval($NMEXCERPTLENGTH);
$content = strip_tags($content);
$url = nm_get_url('post') . $slug;
if (strlen($content) > $len) {
if (function_exists('mb_substr'))
$content = trim(mb_substr($content, 0, $len, 'UTF-8')) . ' [<a href="'. $url . '">read more]</a>';
else
$content = trim(substr($content, 0, $len)) . ' [...]' . $url;
}
return "<p>$content</p>";
}
this adds the link ".../index.php?id=blog&post="
but the last part of the url is missing.
Could somebody help me with this? Thanks in advance