Jump to:

1845 Posts in 1601 Topics by 560 members

Blog Module

SilverStripe Forums » Blog Module » Link to post from comment...

Discuss the Blog Module.

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

Page: 1
Go to End
Author Topic: 3142 Views
  • biapar
    Avatar
    Forum Moderator
    435 Posts

    Link to post from comment... Link to this post

    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

  • Willr
    Avatar
    Forum Moderator
    5490 Posts

    Re: Link to post from comment... Link to this post

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

  • biapar
    Avatar
    Forum Moderator
    435 Posts

    Re: Link to post from comment... Link to this post

    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?

  • carlos
    Avatar
    Community Member
    41 Posts

    Re: Link to post from comment... Link to this post

    Hi biapar,

    $Parent.Link() should do it.

    chao
    Carlos

  • biapar
    Avatar
    Forum Moderator
    435 Posts

    Re: Link to post from comment... Link to this post

    It works. Thank you

    3142 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.