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.

Data Model Questions /

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

2.4: Access to variables in control loop possible?

Go to End

3 Posts   1333 Views


Community Member, 8 Posts

30 August 2012 at 4:59am

Hello dear community,

I want to access the content of a variable which is given in the URL segment


where country is the variable and germany is the content.

I added a public function in the page controller like this:

public function returncountry()
return (isset($_REQUEST['country'])) ? $_REQUEST['country'] :

Now I can access the content of the variable in the template with

<% if returncountry %>
<% else %>
Sorry, no country selected
<% end_if %>

So far, everything works fine.

Now I want to filter a certain table of the database within
a control loop with the content of this variable, but this doesn't work.

Within the control loop, the content of the variable is empty.

The following example code in the template

<% control myFunction %>
<% end_control %>

gives this result:

(blank line)

How can I access userdefined variables within a control loop?

Thanks for your support! :-)


Forum Moderator, 5521 Posts

30 August 2012 at 7:02pm

Use $Top.FunctionName


Community Member, 8 Posts

31 August 2012 at 5:57am

Hi Willr,

thank you so much. It works!