Jump to:

3393 Posts in 976 Topics by 852 members

Template Questions

SilverStripe Forums » Template Questions » Multiple ||

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

Page: 1 2
Go to End
Author Topic: 1435 Views
  • Willr
    Avatar
    Forum Moderator
    5462 Posts

    Re: Multiple || Link to this post

    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.

  • mschiefmaker
    Avatar
    Community Member
    187 Posts

    Re: Multiple || Link to this post

    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;

  • Willr
    Avatar
    Forum Moderator
    5462 Posts

    Re: Multiple || Link to this post

    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.

  • mschiefmaker
    Avatar
    Community Member
    187 Posts

    Re: Multiple || Link to this post

    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

  • Willr
    Avatar
    Forum Moderator
    5462 Posts

    Re: Multiple || Link to this post

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

  • mschiefmaker
    Avatar
    Community Member
    187 Posts

    Re: Multiple || Link to this post

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

    Cheers

    Catherine

    1435 Views
Page: 1 2
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.