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

Multiple ||


Go to End


14 Posts   2720 Views

Avatar
Willr

Forum Moderator, 5523 Posts

25 October 2009 at 2:14pm

Can you post your template file - If you are in the control then the scope of the template changes so functions from the Controller won't be called. Thats possibility you're issue.

Avatar
mschiefmaker

Community Member, 187 Posts

25 October 2009 at 2:20pm

DirectoryPage.ss
<% control Listings %>
...
<% if Offerings %>
<li>Avaliable <% end_if %>

DirectoryPage.php

function Listings() {
return DataObject::get('Member', "IncludeInDirectory = TRUE AND DirState = '" . $this->title . "'");
}
function getOfferings() {
die('');
return True;

Avatar
Willr

Forum Moderator, 5523 Posts

25 October 2009 at 2:26pm

Ah ok that clears things up. Doing <% control Listings %> changes the scope in the template to the 'Member' object rather then the DirectoryPage. To get Offerings to work you need to add that function to your Member decorator (looks like you have decorated it already) so by putting that function in the decorator it should be called.

Avatar
mschiefmaker

Community Member, 187 Posts

25 October 2009 at 3:14pm

Hi Will
Thats got it to apply, thanks. But the actually decision making is still not actually working.

function Offerings() {
return ($this->Referrals) ? true : false;

}
Returns false all the time independant of the value of Referrals

function Offerings() {
return (Referrals) ? true : false;
}

Returns True all the time independant of the value of Referrals

function Offerings() {
return ($this->Referrals=="True") ? true : false;
}
Returns false all the time independant of the value of Referrals

Created Referrals as an Enum rather than a Boolean to enable me to align with users administration database.
'Referrals' => "Enum('TRUE,FALSE','FALSE')",

Any ideas what I am doing wrong?

Thanks

Catherine

Avatar
Willr

Forum Moderator, 5523 Posts

25 October 2009 at 4:23pm

Since this is in your decorator you have to refer to fields as $this->owner->Referrals.

Avatar
mschiefmaker

Community Member, 187 Posts

25 October 2009 at 7:41pm

Thank you very much. Really appreciate your support especially on a Sunday

Cheers

Catherine

Go to Top