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, Ed, biapar, Willr, Ingo, swaiba

Custom Function Call in Page no working in sidebar

Go to End

2 Posts   715 Views


Community Member, 19 Posts

11 November 2011 at 9:02am


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


Forum Moderator, 1377 Posts

12 November 2011 at 6:59am

Edited: 12/11/2011 7:00am

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