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.

General Questions

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

Siteconfig values inside a control doesn't work


Reply

3 Posts   1162 Views

Avatar
ayyurek

20 June 2010 at 7:00am Community Member, 41 Posts

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

20 June 2010 at 12:07pm Forum Moderator, 5511 Posts

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

21 June 2010 at 4:01am Community Member, 41 Posts

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