Jump to:

23368 Posts in 18143 Topics by 2863 members

General Questions

SilverStripe Forums » General Questions » retrieving cms field in function

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Page: 1
Go to End
Author Topic: 433 Views
  • servalman
    Avatar
    Community Member
    211 Posts

    retrieving cms field in function Link to this post

    Hello

    I'm trying to retrieve the value of a cms field inside a function but it does't work

    In code.php

    class SomeClassPage extends Page{
       
       static $db = array(
          'AutorizedContent'   => 'HTMLText',
          'ForbidenContent'   => 'HTMLText'
       );
       

       
       

       function getCMSFields(){
          $f = parent::getCMSFields();
          $f->addFieldToTab('Root.Content.AutorizedContent', new HTMLEditorField('AutorizedContent'));
          $f->addFieldToTab('Root.Content.ForbidenContent', new HTMLEditorField('ForbidenContent'));
          return $f;
       }

    then I have

    class SomeClassPage_Controller extends Page_Controller{
       

       

       
       
       function Authorise(){

          
                            return $this->ForbidenContent;
                         }
                      

    in template

    <% if Authorise %> $ForbidenContent<% end_if %>

    Any idea

    thanks

  • swaiba
    Avatar
    Forum Moderator
    1784 Posts

    Re: retrieving cms field in function Link to this post

    try this in template

    <% if Authorise %> <% control Authorise %> $ForbidenContent<% end_control %><% end_if %>

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