17488 Posts in 4473 Topics by 1978 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 4542 Views |
-
Page independent Content (global Content)

13 July 2009 at 2:33am
Hi folks,
i know someting about the programming model of silverstripe, but one thing is hard to find out (even with the german book SilverStripe). How can i have some page independet content on each page. This content should be editable in the backend.Any suggestions?
-
Re: Page independent Content (global Content)

13 July 2009 at 4:17am
Hi
Usually I add "global" content like this to a Page that only exists once. Like the HomePage.
Then I add a getter Method to the Page baseclass to always have access to the HomePage. Eg:// this belongs in Page_Controller
public function HomePage(){
return DataObject::get_one('HomePage');
}So, if my HomePage has a Field called "GlobalContent", I can output it in any template using:
$HomePage.GlobalContent -
Re: Page independent Content (global Content)

16 July 2009 at 1:04am
Thank you very much!
This works great!
I think SilverStripe should provide such a thing for some global template variables, such as Page Title, Site Name and Tagline (etc.)Greets,
loeppel -
Re: Page independent Content (global Content)

21 February 2010 at 12:24am Last edited: 21 February 2010 12:40am
Hi,
seems like HomePage is a sublcass of Page. And the function returns the first page having the pagetype HomePage.
Is it possible to use the template var $HomePage.GlobalContent inside the content of another page using tinyMCE?
I am just currious because UserDefinedForms is uses $UserDefinedForms inside content which refers to the same function in the contoller.
Does this work for $HomePage.Content aswell inside $Content of the current page (via tinyMCE)?
kind regards
Metin -
Re: Page independent Content (global Content)

22 February 2010 at 6:06pm
Is it possible to use the template var $HomePage.GlobalContent inside the content of another page using tinyMCE?
I am just currious because UserDefinedForms is uses $UserDefinedForms inside content which refers to the same function in the contoller.
UserForms uses a method like http://doc.silverstripe.org/doku.php?id=recipes:customising-content-in-your-templates to get that to work which is a bit nasty but the easiest solution for now.
-
Re: Page independent Content (global Content)

26 February 2010 at 2:50am
Thanks Willr, this looks exactly like what i was looking for
| 4542 Views | ||
|
Page:
1
|
Go to Top |



