Jump to:

23493 Posts in 18996 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » how do i link to a page from my entry page???

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Page: 1
Go to End
Author Topic: 629 Views
  • zim
    Avatar
    Community Member
    135 Posts

    how do i link to a page from my entry page??? Link to this post

    I just need to link to a page on my site.

    I have a home page with one link "click here to enter". Just want to link to a page that is on the same level as my home page. can't believe I can not work this out.

    Do not want to include all of menu1 on entry. I know this must be basic. please help.

  • zim
    Avatar
    Community Member
    135 Posts

    Re: how do i link to a page from my entry page??? Link to this post

    found solution. this works fine from previous post

    "
    Re: How to create a link to an id Link to this post

    30 May 2009 at 3:17pm

    Hi there,

    I don't know if there's a better way of doing it, but I put a function in my Page.php..

    function GetLinkFromID($id = 1) {
    $do = DataObject::get_one('Page', '`SiteTree_Live`.ID = '.$id, true);
    return ($do->URLSegment);
    }

    This will return the link to any page (or class extending page).
    In your template you'd have something along the lines of

    <a href="$GetLinkFromID(12)">

    where 12 is obviously the id of the page you're wanting to link to.

    If you're within a <% control %> loop, you may need to use $Top.GetLinkFromID(12)

    Hope that helps.

    If you found a better way of doing it I'd be interested to hear.
    "

    629 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.