Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Blog Module /

Discuss the Blog Module.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Link to post from comment...


Go to End


5 Posts   3586 Views

Avatar
biapar

Forum Moderator, 435 Posts

7 December 2010 at 9:04pm

Hi,

How create link from comment to post?
Because I've create function that listing latest comments from blog...

This is code:

function LatestComments() {
$member = Member::currentUser();
//if(!$member) return false;
//$comments = DataObject::get("PageComment", "AuthorID = '$member->ID'","Created DESC","",10);
$comments = DataObject::get("PageComment",null,"Created DESC","",10);
return $comments;
}

Thanks

Avatar
Willr

Forum Moderator, 5523 Posts

8 December 2010 at 11:34am

In the template you can simply call $Link to get a link to the specific comment just like you do with pages.

Avatar
biapar

Forum Moderator, 435 Posts

9 December 2010 at 2:47am

Thanks,

I tried. I wrote

<p class="commento"><a href="$Link" title="$Title.XML" class="$LinkingMode">$Comment.XML</a></p>

but link don't works becasue I've as result:

http://red-web-projects/PhPSites/xyz/#PageComment_6

Why?

Avatar
carlos

Community Member, 42 Posts

22 December 2010 at 10:18am

Hi biapar,

$Parent.Link() should do it.

chao
Carlos

Avatar
biapar

Forum Moderator, 435 Posts

5 January 2011 at 2:37am

It works. Thank you