Jump to:

3445 Posts in 1031 Topics by 872 members

Template Questions

SilverStripe Forums » Template Questions » Linking to an internal page

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

Page: 1
Go to End
Author Topic: 485 Views
  • c1rcask8a
    Avatar
    Community Member
    4 Posts

    Linking to an internal page Link to this post

    Hi,

    In one of my templates I want to hardcode a link to the contact page this is what I've got:

    <a href="$BaseHref/contact-us/" id="askBtn" class="largeBtn">Ask A Question</a>

    However the link produced is:

    http://localhost/infoandtrack//contact-us/

    Which still works but is there a better variable to use than $BaseHref which won't add the extra slash?

    Thanks!

  • c1rcask8a
    Avatar
    Community Member
    4 Posts

    Re: Linking to an internal page Link to this post

    Ahh figured it out!

    <a href="./contact-us/" id="askBtn" class="largeBtn">Ask A Question</a>

  • c1rcask8a
    Avatar
    Community Member
    4 Posts

    Re: Linking to an internal page Link to this post

    Got given a better answer,
    In the controller on Page.php:

    public function ContactPage() {
       return UserDefinedForm::get()->filter('ParentID', '0')->first();
    }

    Then back to my link:

    <a href="$ContactPage.Link" id="askBtn" class="largeBtn">Ask A Question</a>

  • c1rcask8a
    Avatar
    Community Member
    4 Posts

    Re: Linking to an internal page Link to this post

    This is incase the client changes the page name etc..

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