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.

Template Questions /

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

very simple question about control


Go to End


2 Posts   1261 Views

Avatar
cobianzo

Community Member, 8 Posts

7 September 2010 at 9:21pm

Hi , there is something I can not understand at all... and it's very simple.

I have a

   NewsHolder extends Page
  

and
   NewItem extends Page 
  

then in
   NewItem_Controller extends Page_Controller
    ...
    function my_NewItem_function ()
       {
          return "this is a test";
       }
  

so in NewsHolder.ss

   <% control AllChildren %>
       <h1> $title </h1>
       <p>   $my_NewItem_function  </p>
   <% end_control %>
  

Very simple, right?
It just doesnt work. Inside the control it just doesnt recognize the method of NewItem. I dont understand it.
If , in the control, i use something like $Top.my_NewsHolder_function --> It works !

I looked for a threath that talks about it but i didnt find it... i thanks any help...

Avatar
cobianzo

Community Member, 8 Posts

7 September 2010 at 11:58pm

I got it...

the function

function my_NewItem_function () 
{ 
return "this is a test"; 
}

should be defined in the model ,, not in the Controller...

cheers