Ok I also have just downloaded Silverstripe and let me say it is THE best site maker I have used. Anyway on to the prolem which is changing the Name of the site and Tagline. Someone else had a problem but the reply was confusing to me. How can I change the name and tagline from the CMS? Please help. Oh and I just notice I posted this in the wrong section. Sorry about that
We've moved the forum!
Please use forum.silverstripe.org for any new questions
(announcement).
The forum archive will stick around, but will be read only.
You can also use our Slack channel
or StackOverflow to ask for help.
Check out our community overview for more options to contribute.
1. First of all, create a special page type called HomePage - do this by creating a new file called HomePage.php inside mysite/code - this should be familiar if you've gone through the first two tutorials.
2. Create the HomePage extends Page class, as well as the HomePage_Controller extends Page_Controller class in the HomePage.php file.
3. Create two data fields on the HomePage class, that will be stored in the database. These will be the site name, as well as the tag line. We also create the form fields so you can edit the value in the CMS using getCMSFields() e.g.
class HomePage extends Page {
static $db = array(
'SiteName' => 'Varchar(100)',
'Tagline' => 'Varchar(100)'
);
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Content.Main', new TextField('SiteName', 'Name of site'));
$fields->addFieldToTab('Root.Content.Main', new TextField('Tagline', 'Tagline of site'));
return $fields;
}
}
class HomePage_Controller extends Page_Controller {
}
4. Run db/build?flush=1, and in the CMS, make sure the "Home" page has the page type "Home Page" (see the Behaviour tab whilst on the page.
5. Open up Page.php, and add two functions. These functions take an instance of HomePage and return the SiteName and Tagline data fields, assuming you'll only ever have one home page. e.g.
class Page extends SiteTree {
function SiteName() {
$homePage = DataObject::get_one('HomePage');
return $homePage ? $homePage->SiteName : false;
}
function Tagline() {
$homePage = DataObject::get_one('HomePage');
return $homePage ? $homePage->Tagline : false;
}
}
class Page_Controller extends ContentController {
}
6. Open up themes/blackcandy/templates/Page.ss and look for "Your Site Name". Replace that text with $SiteName.
7. Do the same as 6), looking for "Your site's tagline here", replacing it with $Tagline
I'll probably add this to the wiki if there's not already a recipe on there for doing this.
Hope this helps!
Cheers,
Sean
or if you dont need to edit the Site name from the CMS (this is currently not supported - you have to edit the template file)
Open themes/ the theme name /templates/Page.ss in a text editor (eg Notepad) and edit the Your Site Name String