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.

General Questions /

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

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

Siteconfig values inside a control doesn't work


Go to End


3 Posts   1512 Views

Avatar
ayyurek

Community Member, 41 Posts

20 June 2010 at 7:00am

As I am building a multilingual site, I decided to add some labels to siteconfig. As an example,

<% control Testimonials %>
<h3>$Title</h3>
<p>$Summary</p>
<% end_control %>
<a href="testimonials-page">$SiteConfig.LabelSeeAllTestimonials</a>

works perfectly. But,
<% control Testimonials %>
<h3>$Title</h3>
<p>$Summary</p>
<a href="$Link">$SiteConfig.LabelReadMore</a>
<% end_control %>

doesn't work. I also tried
<% control Testimonials %>
<h3>$Title</h3>
<p>$Summary</p>
<a href="$Link"><% control SiteConfig %>$LabelReadMore<% end_control %></a>
<% end_control %>

But anyway couldn't have success. Is there such a rule about SiteConfig? So that we can not use them inside controls? Or is there another trick?
I will be glad if anybody has an idea.
Thanks

arda

Avatar
Willr

Forum Moderator, 5523 Posts

20 June 2010 at 12:07pm

This is because SiteConfig is a property on the top level controller, not your object so it won't be in scope. Using $Top to go back to the top level should work..

<% control Top %>
$SiteConfig.Title
<% end_control %>

Avatar
ayyurek

Community Member, 41 Posts

21 June 2010 at 4:01am

Thank you very much Willr :) you really saved my time.