Dashboard pages

Permalink
One thing is not clear to me after readinghttp://www.concrete5.org/documentation/introduction/dashboard...

I cannot seem to add subpages. The instructions as provided on that page simply do not work. Does anyone have some sort of minimal working concept that I could have a look at instead?

I found a similar forum post [1] on the subject, but the replies were not really statisfactory in the sense that I was unable to figure out what the minimal addition was that caused a page to list as a subpage.

[1]http://www.concrete5.org/community/forums/customizing_c5/extending-...

JoostRijneveld
 
goldhat replied on at Permalink Reply
Below is the install() function from a package controller I made recently (Page Importer) it installs 3 dashboard pages:

public function install() {  
  $pkg = parent::install();
  Loader::model('single_page'); 
  $sp = SinglePage::add('/dashboard/'.$this->pkgHandle.'/', $pkg);
  $sp->update(array('cName'=>t("Page Importer")));
  $sp = SinglePage::add('/dashboard/'.$this->pkgHandle.'/import', $pkg);
  $sp->update(array('cName'=>t("Import Page")));
  $sp = SinglePage::add('/dashboard/'.$this->pkgHandle.'/export', $pkg);
  $sp->update(array('cName'=>t("Export Page")));
}


I'm presuming you're making a package. The process would probably be the same if you're somewhere else in the system. You have to load the model single_page then use the add function. The code below might be a little clearer because it doesn't have the variables that my package example has but it's the same idea.

Loader::model('single_page');
$sp = SinglePage::add('/dashboard/my_dashpage/my_dashsubpage');


Now that code in the examples installs the single page when you install the package saving you having to go to the single pages in the C5 admin and manually install it. You also have to make the single page in your package, or if you're not making a package, inside your C5 site:

In a package the location would be:

/packages/my_package/singles_pages/dashboard/my_dashpage.php
/packages/my_package/singles_pages/dashboard/my_dashsubpage.php

Outside of a package the location would be trimmed to:

/singles_pages/dashboard/my_dashpage.php
/singles_pages/dashboard/my_dashsubpage.php

And then if you want to have a custom controller, which you usually will... you add that as well and I think that part is well covered inhttp://www.concrete5.org/documentation/introduction/dashboard...