3214 Posts in 848 Topics by 810 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 857 Views |
-
use template control within content

24 November 2010 at 3:08am
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
-
Re: use template control within content

24 November 2010 at 5:42pm
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.
-
Re: use template control within content

24 November 2010 at 9:45pm
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.
.......thinking....
-
Re: use template control within content

24 November 2010 at 10:31pm
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'));
-
Re: use template control within content

24 November 2010 at 10:53pm
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...
| 857 Views | ||
|
Page:
1
|
Go to Top |


