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.

Archive /

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

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

Admin my site - extending SS main menu?


Go to End


2 Posts   1520 Views

Avatar
carlossg

Community Member, 13 Posts

1 August 2008 at 12:37pm

Hi all, first post.

I'm developing a website for a secondary school, managing subjects, teachers, departments, students and all their relations.

I've created some DataObjects to manage subjects, teachers, etc.
My doubt comes at time of adding new subjects (i.e). I've created a subject page with a TableField control to enter new subjects, and created this page-type in Site Content (in the tree).
Works fine, but I don't find the place to put it (Site Content) suitable. Would not be more reasonable put all the admin pages (add subjects, teachers, ...) in a new tab in SS main menu?, i mean right beside "Site Content","Files & Images", "Newsletters", etc. and manage this pages with a tree?. the answer is yes!! (i guess). but how?
How do I add a new tab y main menu?, how do I create a tree with all the admin pages?, Is too hard to do what i am asking for? Does it differ too much from creating pages for every admin task and add them in site tree?.

Hope don't confuse you...

Thanks a lot and any ideas will be gladed.

Avatar
Willr

Forum Moderator, 5523 Posts

1 August 2008 at 6:34pm

Not a straight forward thing to do well but First Add the panel to the cms by adding this to you _config file.

// Add Polls to the CMS
Object::addStaticVars('LeftAndMain', array(
   'extra_menu_items' => array(
		'Custom Panel' => 'admin/custompanel/',
	)
));

Director::addRules(100, array(
	'admin/custompanel/$Action/$ID/$OtherID' => 'CustomPanel',
));

This will add a Custom Panel link and point to the CustomPanel.php which you will need to create, which needs to look something like -

mysite/code/CustomPanel.php

<?php
class CustomPanel extends GenericDataAdmin {
	
	static $data_type = 'DataObjectName'; 
	static $result_columns = array(' Fields you want to show ');
  	
	function init() {
 
	}
	
	public function getLink($action = null, $id = 0) {
		
	}
	
	public function performSearch(){
	 
	}
	
	function getEditForm($id){
		// fields on your dataobject you need to edit
		
      	return new Form($this, 'EditForm', $fields, $actions);
	}
	
	function save($data, $form){ }

}

?>