Overriding the core theme for the dashboard
Permalink
I'm not sure if this is possible, or why it's not enabled.
I would like to use page types in the dashboard. For the last several months I've been working on honing and abstracting dashboard CRUD interfaces, however they all run up against a pretty big limitation when trying to make derivatives from the original package. There's a lot of find/replace that needs to be done for everything to get a new package that could be installed.
What I'm thinking of doing is making a package that would have a dashboard tool to add new dashboard pages. These dashboard pages, when created, would also add an attribute set, which would then be used to generate out the dashboard edit interface for this custom page/thing/whatever. This should be pretty simple to do, and give me a lot of flexibility to just go to a dashboard page and generate out really pretty solid interfaces, most likely with the option to allow people to include custom elements (matching the name) for the actual edit/add screen so it could be customized, a page type, etc.
Tonight as I tried to do a few tests for it, I saw a pretty big potential snag. The pages in the dashboard all get the dashboard theme applied no matter what. I tried overriding from both a package's on_start method and site_view_paths.php, but neither took.
If I comment out the 'break' in this function on the view, it works to override and use my own dashboard-like theme with a page type instead of a single page:
I tried using overrideCoreByPackage() in my package on_start as well, but this didn't appear to get it to use my /package/libraries/view.php file.
I see a few potential things that could be done to get around this:
1) Make it a forward-facing interface. I really don't like this, but if it's necessary for the marketplace, I will do it.
2) Make it possible to override the view object from a package
3) Remove the break in the loop to get the theme file. I have no idea what this would do to page execution times, though
4) Change around the check on line 884 of view.php:
Current:
Proposed:
This checks the page before the view path, but that might not be best, either.
I'd really like to figure out a way to do this. I think it could open up a whole lot of functionality to developers to be able to specify a theme and a page type in the dashboard...
I would like to use page types in the dashboard. For the last several months I've been working on honing and abstracting dashboard CRUD interfaces, however they all run up against a pretty big limitation when trying to make derivatives from the original package. There's a lot of find/replace that needs to be done for everything to get a new package that could be installed.
What I'm thinking of doing is making a package that would have a dashboard tool to add new dashboard pages. These dashboard pages, when created, would also add an attribute set, which would then be used to generate out the dashboard edit interface for this custom page/thing/whatever. This should be pretty simple to do, and give me a lot of flexibility to just go to a dashboard page and generate out really pretty solid interfaces, most likely with the option to allow people to include custom elements (matching the name) for the actual edit/add screen so it could be customized, a page type, etc.
Tonight as I tried to do a few tests for it, I saw a pretty big potential snag. The pages in the dashboard all get the dashboard theme applied no matter what. I tried overriding from both a package's on_start method and site_view_paths.php, but neither took.
If I comment out the 'break' in this function on the view, it works to override and use my own dashboard-like theme with a page type instead of a single page:
private function getThemeFromPath($path) { // there's probably a more efficient way to do this $theme = false; $txt = Loader::helper('text'); foreach($this->themePaths as $lp => $layout) { if ($txt->fnmatch($lp, $path)) { $theme = $layout; // break; } } return $theme; }
I tried using overrideCoreByPackage() in my package on_start as well, but this didn't appear to get it to use my /package/libraries/view.php file.
I see a few potential things that could be done to get around this:
1) Make it a forward-facing interface. I really don't like this, but if it's necessary for the marketplace, I will do it.
2) Make it possible to override the view object from a package
3) Remove the break in the loop to get the theme file. I have no idea what this would do to page execution times, though
4) Change around the check on line 884 of view.php:
Current:
if (isset($this->themeOverride)) { $theme = $this->themeOverride; } else if ($this->controller->theme != false) { $theme = $this->controller->theme; } else if (($tmpTheme = $this->getThemeFromPath($viewPath)) != false) { $theme = $tmpTheme; } else if (is_object($this->c) && ($tmpTheme = $this->c->getCollectionThemeObject()) != false) { $theme = $tmpTheme; } else { $theme = FILENAME_COLLECTION_DEFAULT_THEME; }
Proposed:
if (isset($this->themeOverride)) { $theme = $this->themeOverride; } else if ($this->controller->theme != false) { $theme = $this->controller->theme; } else if (is_object($this->c) && ($tmpTheme = $this->c->getCollectionThemeObject()) != false) { $theme = $tmpTheme; } else if (($tmpTheme = $this->getThemeFromPath($viewPath)) != false) { $theme = $tmpTheme; } else { $theme = FILENAME_COLLECTION_DEFAULT_THEME; }
This checks the page before the view path, but that might not be best, either.
I'd really like to figure out a way to do this. I think it could open up a whole lot of functionality to developers to be able to specify a theme and a page type in the dashboard...
Oh, and currently the 'selected' theme if you choose design for any dashboard pages is whatever the current is, so for option 4, the dashboard pages would all need to have their own template set...
Huh, guess this thread isn't right. For some reason I was thinking I needed to show the page type from the theme. But if it's just a page type in a package, or in the outer /page_types directory then it's displayed in the view.php file. That's exactly what I need!
Can someone delete this?
Can someone delete this?