3214 Posts in 848 Topics by 810 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 750 Views |
-
How to: Same info on every page, edit from one source by user?

4 September 2009 at 9:48pm Last edited: 4 September 2009 9:48pm
I'm sure this is prob quite simple but as a noob I can't figure it out.
I need contact info (call now on: blah) on all pages with the Page PageType.
I want it to come from a single source so it only needs changing once.
I also need it to be editable in the CMS by the user?What is the best way to produce this please?
All help appreciated! Thanks
-
Re: How to: Same info on every page, edit from one source by user?

4 September 2009 at 11:17pm Last edited: 4 September 2009 11:20pm
Create a ContactPage pagetype to admin the contactdetails.
To ensure you only have one contactpage add:
function canCreate() {
if(DataObject::get_one('ContactPage')) {
return false;
} else {
return true;
}
}In Page_Controller add
public function ContactDetails() {
if(class_exists("ContactPage")) return DataObject::get_one("ContactPage");
}in template use control ContactDetails to display the info.
-
Re: How to: Same info on every page, edit from one source by user?

6 September 2009 at 9:29pm Last edited: 6 September 2009 9:31pm
Hi could you please give me some more help, I'm really new to this and haven't managed to get this to work.
I've created a new PageType = ContactPage.php in mysite/code
<?php
/**
* Defines the ContactPage page type
*/
class ContactPage extends Page {
static $db = array(
);
static $has_one = array(
);}
class ContactPage_Controller extends Page_Controller {
public function ContactDetails() {
if(class_exists("ContactPage")) return DataObject::get_one("ContactPage");
}}
function canCreate() {
if(DataObject::get_one('ContactPage')) {
return false;
} else {
return true;
}
}?>
I'm not sure if this is correct?
This new PageType is then in the CMS (after Flush) and I've made a ContactPage with the details on.
Then called it in the the main template (Page.ss) like so:
<div id="content">
$Layout
$ContactDetails
</div>I'm then expecting the ContactPage from the CMS to display its info at the bottom of every page..??
Help appreciated? Thanks -
Re: How to: Same info on every page, edit from one source by user?

11 September 2009 at 7:45am
You may want to take a look at the following thread. It is a little different, in that it explains how to display footer information entered on one page in the CMS, in this case in the homepage on all pages. But the homepage could be easily changed to any page.
Dynamic Footer
http://silverstripe.org/general-questions/show/260690#post260690Hope it helps,
Sam -
Re: How to: Same info on every page, edit from one source by user?

11 September 2009 at 10:25am
Thanks for the link! Sounds good, I'll try it out! nice one Happy Sadhu
| 750 Views | ||
|
Page:
1
|
Go to Top |



