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

Custom Function Call in Page no working in sidebar


2 Posts   364 Views


11 November 2011 at 9:02am Community Member, 19 Posts


I have defined a custom function that is called by the Content function of the Page_Controller. The function replaces a string with a customer image throughout my site.

This render works on any page content. However, when I attempt to call the function from within by sidebar that is included in a page via the include statement it does not render. It just shows the text. So what am I doing wrong?

Here is some code.

class Page_Controller extends ContentController {

function Content() {
$thereturn=str_replace('$PayPalFormsubdomain', $this->PayPalFormsubdomain(), $this->Content);
return $thereturn ;

function PayPalFormsubdomain() { return 'some text'; }

In my
<% include SideNav %>

<% control ALLChildren %>
<% end_control %>

The result displays:


Instead of: some text


12 November 2011 at 6:59am (Last edited: 12 November 2011 7:00am), Forum Moderator, 1091 Posts

When you loop a set of pages like this:

<% control AllChildren %>
<% end_control %>

what you get is a set of Page objects (the DataModel), not Page_Controllers! So from within that loop you don't have access to any controller function and now your template will just display the content as is...

To fix that, you need to create a function in you Page class, that will do the replacing...