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.

Template Questions

use template control within content


5 Posts   1009 Views


24 November 2010 at 3:08am Community Member, 18 Posts

the idea is the following:

put into the content ( which is edited with the tiny ) a control tag.
eg. <% control Page(url) %>$Content<% end_control %>

if you add the Control function in the Page_Controller like this:

public function Content(){
$MySSViewer = new SSViewer_FromString($this->Content);
return $this->renderWith($MySSViewer);

it looks like it would to the trick. But is does not !
It only replaces the variables eg. $Title or $Content, but does not execute the Controller function(s).
eg. if there is a news listing at the target page, the listing is not shown, since the listing code is not executed.

is there a way to achive this ?

do you need more information ?

thx for any help


24 November 2010 at 5:42pm Forum Moderator, 5511 Posts

When you are controlling in the template (such as <% control Page(url) %>) you only get the data record and *not* the controller. In this case your content method needs to be in the Page class rather than Page_Controller.


24 November 2010 at 9:45pm Community Member, 18 Posts

hmm so first we have the Content function in the controller.
this one renders the content with renderWith.

Within the content it finds the $Content and now finds the Content() function in the Page class.

until this step it all works fine.

but now I have a loop. since it always finds the Content() funktion it will use this over and over again.



24 November 2010 at 10:31pm Forum Moderator, 5511 Posts

You need to make a slight change to your code

$MySSViewer = new SSViewer_FromString($this->Content);

SS will resolve $this->Content to that function so you may want to play around with getting the db object directly

$MySSViewer = new SSViewer_FromString($this->dbObject('Content'));


24 November 2010 at 10:53pm Community Member, 18 Posts

I already solved this by not using the Content function.

the special code which will be placed into the content field looks like this now (fater being replaced):

<% control Page(url) %>$SpecialContent<% end_control %>

this way the loop is prevented.

if the target page uses its own template and within there are calls to functions within the controller class, it will "fail".
Sinc I want the "complete" result and not only the result if the content db field.
If I copy the special functions from the page_controller into the Page class it works. I get the complete result of the targetet page with its template. But this way could not be the solution, since the functions will be on two places...