Jump to:

23370 Posts in 18160 Topics by 2864 members

General Questions

SilverStripe Forums » General Questions » Siteconfig values inside a control doesn't work

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

Page: 1
Go to End
Author Topic: 1139 Views
  • ayyurek
    Avatar
    Community Member
    41 Posts

    Siteconfig values inside a control doesn't work Link to this post

    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

  • Willr
    Avatar
    Forum Moderator
    5489 Posts

    Re: Siteconfig values inside a control doesn't work Link to this post

    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 %>

  • ayyurek
    Avatar
    Community Member
    41 Posts

    Re: Siteconfig values inside a control doesn't work Link to this post

    Thank you very much Willr you really saved my time.

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