Jump to:

3445 Posts in 1031 Topics by 872 members

Template Questions

SilverStripe Forums » Template Questions » Linking to Specific Pages

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

Page: 1
Go to End
Author Topic: 2539 Views
  • Novabomb
    Avatar
    Community Member
    2 Posts

    Linking to Specific Pages Link to this post

    I am trying to find how you can link straight to a page via the templates without an luck.

    First Example: I would like to have the Logo link to the homepage, is there a function for this or do I just need to do this manually?

    Second Example: I would like to link to a Trademarks page that is not on the menu or search anywhere, same question as above.

    Thanks

  • Nivanka
    Avatar
    Community Member
    395 Posts

    Re: Linking to Specific Pages Link to this post

    I think doing it manually will make things much easier for you

  • chrisjlee
    Avatar
    Community Member
    5 Posts

    Re: Linking to Specific Pages Link to this post

    I'd like to know this answer as well.

  • Aram
    Avatar
    Community Member
    598 Posts

    Re: Linking to Specific Pages Link to this post

    You need to create a function which returns the page you want to link to.

    Something like:

    public function GetHomePage(){

    return DataObject::get_one("HomePage");

    }

    You can then use $GetHomePage.Link to return the URL.

    If you need to be more specific then you can add a filter to the query.

    Aram

  • Nivanka
    Avatar
    Community Member
    395 Posts

    Re: Linking to Specific Pages Link to this post

    Hi, I created a widget with which you can select any Page type and list them on any of the web pages you prefer. Hope this will be useful.

    Check it out, I am posting a ZIP file, I am on windows at the moment will post the widget at the widget list soon as I get in to my laptop

    Would like to hear any comments about this widget

    Attached Files
  • Samba Sam
    Avatar
    Community Member
    85 Posts

    Re: Linking to Specific Pages Link to this post

    Hi,

    What would I use to link my logo to my homepage, if I don't have a specific HomePage type.
    My homepage uses the default Page Type.

    This doesn't work:
    public function GetHomePage(){return DataObject::get_one("HomePage");}

    Is there something I could do with <% control Page(home) %>?

    I know I could just use a href="/" , but I am curious about how to link to specific pages in a generic template.

    Thanks,
    Sam

  • Aram
    Avatar
    Community Member
    598 Posts

    Re: Linking to Specific Pages Link to this post

    hmm, well if you cant do it with a class name then you are left with any of the other column in the database, Title, ID, URLSegment etc.

    If you can't find a way to define it in a database query (or some other logic) then I guess you would have to hard code it....

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