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.

Archive /

Our old forums are still available as a read-only archive.

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

Accessing variables within a <control>


Go to End


5 Posts   2670 Views

Avatar
Fuzz10

Community Member, 791 Posts

21 September 2007 at 8:35pm

Hi !

I'm currently working on a dual-language website. I tied the word-list to the homepage so the user can maintain this list themselves. Accessing theses variables in the template works like a charm, except when I'm in a control block.

Here's an example (I'm in the homepage template):

<% control LatestNews %>
	<div class="case_news">
	    <h2>$MetaTitle</h2>
    	    $MetaDescription
    	    $Read_more
	</div>
<% end_control %>

SS cannot access the $Read_more variable now (since it's linked to the Homepage).

If I place $Read_more _outside_ of the control block , it will work.

Anyone knows how i can access the variable from within the control ?

Thanks !

Avatar
Fuzz10

Community Member, 791 Posts

24 September 2007 at 8:53pm

Thanks for your reply.

$Link produces a correct hyperlink to the item, but that is not my problem. I can't seem to figure out how to switch languages. "Read more" should read "lees meer" in Dutch (so the $Read_more string only contains text , no URL or anything.

Avatar
Fuzz10

Community Member, 791 Posts

25 September 2007 at 6:59pm

Thanks, but nope. Can't seem to get to that variable (or to a function defined in the homepage-controller).

Avatar
Alex S

Community Member, 30 Posts

9 September 2008 at 3:59am

Having the same issue, no joy so far...

Avatar
Fuzz10

Community Member, 791 Posts

9 September 2008 at 7:22pm

Alex :

try :
$Top.variable