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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Customising the CMS /

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

Decorating/Extending AssetAdmin - so that it shows a different folder

Go to End

3 Posts   1457 Views


Community Member, 33 Posts

4 November 2010 at 11:39am


In the CMS I need the AssetAdmin to show a custom folder. I might be going around this the wrong way. I'm try to decorate AssetAdmin.

In my _config.php

I've got

Object::add_extension('AssetAdmin', 'MemberAssets');

Then MemberAssets is


class MemberAssets extends DataObjectDecorator  {
	function init() {
 			echo 'init happening - maybe two lots of data decoratoring does not work';

	 * Return the entire site tree as a nested UL.
	 * @return string HTML for site tree
	public function SiteTreeAsUL() {

		$obj = singleton('Folder');
		$obj->setMarkingFilter('ClassName', ClassInfo::subclassesFor('Folder'));
		$obj->markPartialTree(30, null, "ChildFolders");

		if($p = $this->currentPage()) $obj->markToExpose($p);

		// getChildrenAsUL is a flexible and complex way of traversing the tree
		$siteTreeList = $obj->getChildrenAsUL(
			'"<li id=\"record-$child->ID\" class=\"$child->class" . $child->markingClasses() .  ($extraArg->isCurrentPage($child) ? " current" : "") . "\">" . ' .
			'"<a href=\"" . Controller::join_links(substr($extraArg->Link(),0,-1), "show", $child->ID) . "\" class=\"" . ($child->hasChildFolders() ? " contents" : "") . "\" >" . $child->TreeTitle() . "</a>" ',

		// Wrap the root if needs be
		$rootLink = $this->Link() . 'show/root';
		$baseUrl = Director::absoluteBaseURL() . "assets/";
		if(!isset($rootID)) {
			$siteTree = "<ul id=\"sitetree\" class=\"tree unformatted\"><li id=\"record-root\" class=\"Root\"><a href=\"$rootLink\"><strong>EXTENDED{$baseUrl}</strong></a>"
			. $siteTreeList . "</li></ul>";

		return $siteTree;


I've got init happening - maybe two lots of data decoratoring does not work showing.

Does any have ideas about what I've doing wrong? or there another solution to my problem ?




Community Member, 46 Posts

3 February 2012 at 5:49am

I've been trying the same. But yeah, the SiteTreeAsUl extend doesn't work. Have you found a solution yet?

I think it's easier to just set the rootfolder, but haven't really found out yet how to.


Community Member, 33 Posts

3 February 2012 at 12:53pm


Yes I did solve it.

What I've got is

class MemberAssets that extends AssetsAdmin

Then I've got some like

public function SiteTreeAsUL() {
		 if(Permission::checkMember(Member::currentUser(), "ADMIN")) {
			 return  $this->AdminSiteTreeAsUL();
		 } else {
			 return  $this->UserSiteTreeAsUL();


Then tidy up the CMS menu in the _config.php I've got

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

CMSMenu::remove_menu_item('MemberAssets');//this seems to be a bit hack but it works
CMSMenu::add_link('AssetAdmin', 'Files', 'admin/files', $priority = 2);

I hope that helps