Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

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.

Customising the CMS /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Custom own LeftAndMain and CMS left menu


Go to End


1655 Views

Avatar
szmitek

Community Member, 2 Posts

14 February 2015 at 1:59am

Edited: 14/02/2015 2:18am

I have created class which extends LeftAndMain and overwritten Content() method (I replaced real name with "PageName"):

class PageName extends LeftAndMain
{
   //(...)
   function Content()
   {
      parent::Content();
      //(...)
      return $this->renderWith($_SERVER['DOCUMENT_ROOT'] . "/themes/simple/templates/PageName.ss");
   }
}

Template "themes/simple/templates/PageName.ss":
<% require css('http://fonts.googleapis.com/css?family=Source+Sans+Pro:400&amp;subset=latin,latin-ext') %>
<% require css("themes/simple/css/PageName") %>
<main data-pjax-fragment="Content">
   Page content
</main>

Link to this LeftAndMain page is visible in CMS left admin menu but page can be accessed only by typing its URL in browser address field. Browser does not go to my page after click page item in menu. I cannot also go from my page to Pages and Assets module via menu. I tried overwriting constructor and init() method:
function __contruct(){parent::__contruct();$this->Content();}
function init(){parent::init();return $this->Content();}

I also tried creating PageName_Content.ss in "themes/simple/templates/PageName_Content.ss" template and putting PHP script and template in a directory in the main website directory like in Silversrpe add-in Dashboard. I add Dashboard add-in to CMS too and I cannot go to this module, eg. CMS via menu item. Version of Silverstripe is 3.1.1. Why page can be accessed by typing its address but I cannot click on menu item and go to page.How to create new main page in CMS which I can go to via CMS menu with custom template? How to connect the page with the menu and load a page content with the template correctly? Could you help me?