Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-07-02 17:49:55

crosbie
New Member
From: Ashford, Kent, UK
Registered: 2009-07-02
Posts: 9
Website

comment_permlink aka <txp:comment_permlink>

As per the Textbook: <txp:comment_permlink>

The comment_permlink tag is either a single or a container tag which is used to return the permanent link of the article comment being displayed. The container tag wraps the text assigned to the link.

Unfortunately, it doesn’t appear to function as a single tag (in the way txp:permlink does). It is theoretically possible this is by design, but in case it isn’t…

I have provided a fix to the respective function ‘comment_permlink’ in taghandlers.php:

function comment_permlink($atts, $thing=NULL)
{
	global $thisarticle, $thiscomment;

	assert_article();
	assert_comment();

	extract($thiscomment);
	extract(lAtts(array(
		'anchor' => ($thing===NULL)?'':empty($thiscomment['has_anchor_tag']), 
	),$atts));

	$dlink = permlinkurl($thisarticle).'#c'.$discussid;

	if ($thing===NULL)
		return $anchor?'c'.$discussid:$dlink;

	$thing = parse($thing);

	$name = ($anchor ? ' id="c'.$discussid.'"' : '');

	return tag($thing,'a',' href="'.$dlink.'"'.$name);
}

The function remains unchanged when the tag is used as a container, but if used singly it either returns the plaintext URL or (if anchor=“1”) the comment ID anchor, e.g. c000234

Offline

#2 2009-07-04 08:04:58

crosbie
New Member
From: Ashford, Kent, UK
Registered: 2009-07-02
Posts: 9
Website

Re: comment_permlink aka <txp:comment_permlink>

To achieve the same effect (without changing behaviour of comment_permlink) I suppose one can do this:

<a href="<txp:permlink />#c<txp:comment_id />" ></a>

Offline

#3 2009-07-04 08:12:47

crosbie
New Member
From: Ashford, Kent, UK
Registered: 2009-07-02
Posts: 9
Website

Re: comment_permlink aka <txp:comment_permlink>

That ‘workaround’ works just fine. Sorry for wasting everyone’s time. Case closed. :-}

Offline

#4 2017-03-15 07:48:50

alicson
Member
Registered: 2004-05-26
Posts: 465
Website

Re: comment_permlink aka <txp:comment_permlink>

Just want to say this was helpful (eight years later). Thanks!


textpattern.org :: find and share Textpattern resources
docs.textpattern.io :: Textpattern user documentation

Offline

Board footer

Powered by FluxBB