Jump to:

17452 Posts in 4473 Topics by 1971 members


SilverStripe Forums » Archive » I'm confused...Could someone help me if they aren't busy?

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo, simon_w

Page: 1
Go to End
Author Topic: 1282 Views
  • Ghostdemon
    Community Member
    2 Posts

    I'm confused...Could someone help me if they aren't busy? Link to this post

    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

  • Sean
    Forum Moderator
    921 Posts

    Re: I'm confused...Could someone help me if they aren't busy? Link to this post

    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!


  • Willr
    Forum Moderator
    5511 Posts

    Re: I'm confused...Could someone help me if they aren't busy? Link to this post

    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

Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.