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 /

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

customising content in template


Go to End
Reply


2 Posts   1270 Views

Avatar
me.yay

Community Member, 14 Posts

1 March 2010 at 3:01am

Edited: 01/03/2010 3:02am

Hey Silverstripers,

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

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

Community Member, 14 Posts

5 March 2010 at 9:19am

hmmm...

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

helloworld