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

[SOLVED] Adding own page to CMS


Go to End


5 Posts   1573 Views

Avatar
Eurisko

Community Member, 27 Posts

6 November 2015 at 1:38am

Edited: 06/11/2015 1:44am

Hi

I'd like to add my own page that handles some bit and bobs that aren't relevant to the website management (analytics API stuff)

I want to give my user some control over this on a page in the admin. I've run into the following problems

When I extend CMSMain,

    class Analytics extends CMSMain {
        private static $menu_title = "Analytics";
        private static $url_segment = 'analytics';
        private static $menu_priority = 8;
        private static $menu_icon = 'site/icons/analytics.png';
    }

And have an "Analytics.ss" page in the templates directory. The analytics page in the CMS is the "Pages" page (The one that lets you manage the pages)

When I extend LeftAndMain

    class Analytics extends LeftAndMain {
        private static $menu_title = "Analytics";
        private static $url_segment = 'analytics';
        private static $menu_priority = 8;
        private static $menu_icon = 'site/icons/analytics.png';

    }

And have an "Analytics_left.ss", "Analytics_right.ss", "Analytics.ss" (to be thorough) in templates. I just get a blank page that looks malformed with "Analytics" at the top where the title goes.

It's also showing the icon I use, next to the title, so I'm guessing this might be the right way to go.

My question is. What do I need to do to get my own .SS file in there.

Thanks

Avatar
martimiz

Forum Moderator, 1391 Posts

6 November 2015 at 6:05am

Something like this:

Analytics.php:

    class Analytics extends LeftAndMain {
        private static $menu_title = "Analytics";
        private static $url_segment = 'analytics';
        private static $menu_priority = 8;
        private static $menu_icon = 'site/icons/analytics.png';
    }

templates/Includes/Analytics_Content.ss:

<div class="cms-content cms-tabset center $BaseCSSClasses" data-layout-type="border" data-pjax-fragment="Content">

	<div class="cms-content-header north">
		<div class="cms-content-header-info">
			<h2>
				<% include CMSSectionIcon %>
				<% if $SectionTitle %>
					$SectionTitle
				<% else %>
					<% _t('Analytics.Title', 'Analytics') %>
				<% end_if %>
			</h2>
		</div>
	</div>

	<div class="cms-content-fields center ui-widget-content" data-layout-type="border">
		--- YOUR CONTENT HERE ---
	</div>
</div>

Do a ?flush=all to make the template available. Look in framework/admin/templates/Includes to se examples of ModelAdmin, or cms/templates/Includes for AssetAdmin and others: besides xxx_Content.ss looks like you also have xxx_Tools.ss, xxx_EditForm.ss to play with :)

Avatar
Eurisko

Community Member, 27 Posts

18 November 2015 at 10:47pm

Hi martimiz

Thanks for the response. I still get the same result though. I did a flush=all. I had a look in the framework/admin/templates/Includes but can't find any insights as to what might be the problem.

Avatar
Eurisko

Community Member, 27 Posts

19 November 2015 at 3:45am

Okay I got it working.

Turns out that putting the content file in /themes/myTheme/templates/Includes doesn't work, there's no theme selected in the admin. The content file needs to go in /mySite/templates/Includes.

Got there in the end :)

Avatar
martimiz

Forum Moderator, 1391 Posts

21 November 2015 at 4:54am

Hmm, there is some sort of logic in that - the theme is aimed at the frontend, so I guess everything CMS should be placed elsewhere. But this is just a feeling - I always place these themes in mysite and never actually checked if the CMS looks in the theme as well...

Glad you got it sorted :)