Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Custom Function but parameter is always NULL

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

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

Page: 1 2
Go to End
Author Topic: 3148 Views
  • Sam
    Avatar
    Administrator
    679 Posts

    Re: Custom Function but parameter is always NULL Link to this post

    It's not a bug.

    What's happening is that the getPage() method defines an accessor for the $obj->Page property. So, in your PHP code, if you write $obj->Page, then it will get the value of that property by executing $obj->getPage().

    Properties can't have arguments, so no arguments are ever passed to getPage() when it's used in this way.

    The best solution here is to rename getCopyrightRange() to CopyrightRange().

  • Sean
    Avatar
    Forum Moderator
    921 Posts

    Re: Custom Function but parameter is always NULL Link to this post

    Makes sense, Sam.

    Just a bit of a gotcha when it comes to using variables in templates, I guess.

    Sean

    3148 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.