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've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Template Questions /

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

Linking to an internal page


Go to End


4 Posts   1754 Views

Avatar
c1rcask8a

Community Member, 4 Posts

22 February 2013 at 10:07am

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!

Avatar
c1rcask8a

Community Member, 4 Posts

22 February 2013 at 10:13am

Ahh figured it out!

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

Avatar
c1rcask8a

Community Member, 4 Posts

22 February 2013 at 10:30am

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>

Avatar
c1rcask8a

Community Member, 4 Posts

22 February 2013 at 10:31am

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