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.

Customising the CMS

customising content in template


Reply

2 Posts   1037 Views

Avatar
me.yay

1 March 2010 at 3:01am (Last edited: 1 March 2010 3:02am), Community Member, 14 Posts

Hey Silverstripers,

I want to $URLSegment to be display inside pages content. I followed instructions from [url]http://doc.silverstripe.org/doku.php?id=recipes:customising-content-in-your-templates[/url].

My page controller has this method:

   function Content() {
          return str_replace('$myURLSegment', $this->URLSegment, $this->Content);
   }

This method should replace all appearance from $myURLSegment in Content (via TinyMCE) while rendered in the browser. But it doesn't.

UserForms does it like that:

   /**
    * Using $UserDefinedForm in the Content area of the page shows
    * where the form should be rendered into. If it does not exist
    * then default back to $Form
    *
    * @return Array
    */
   public function index() {
      if($this->Content && $form = $this->Form()) {
         $hasLocation = stristr($this->Content, '$UserDefinedForm');
         if($hasLocation) {
            $content = str_ireplace('$UserDefinedForm', $form->forTemplate(), $this->Content);
            return array(
               'Content' => $content,
               'Form' => ""
            );
         }
      }
      return array(
         'Content' => $this->Content,
         'Form' => $this->Form
      );
   }

The function is not called Content() and an array is returned. And Idea how to make this content beeing displayed?

kind regards
Metin

Avatar
helloworld

5 March 2010 at 9:19am Community Member, 14 Posts

hmmm...

e.g. $form = $this->Form() to $form == $this->Form() ...??

helloworld