Change icons in dashboard sitemap based on page type/attribute.

Permalink 1 user found helpful
Is there an easy, or easy-ish, way to change the icons in the dashboard sitemap based on page type or an attribute? To be clear, I am NOT talking about the "Page Type Icons" when choosing a page type.

I am referring to the little icons that appear next to pages in the sitemap.

I know it can be done for single pages, but what I need is a way to quickly distinguish a specific page type from others and this would be a great way of doing that.

Many thanks!

glockops
 
tdpss replied on at Permalink Reply
tdpss
Hope someone will respond, as I've often thought that listing the page type with the page name would be helpful in the flat sitemap dump. I suspect that since dashboard code is part of the core, it's not something we would mess with. So we're need to see if the C5 developers think this is a easy thing to do.
aghouseh replied on at Permalink Reply
aghouseh
I would be pleased to hear if someone has a solution for this. I know the functionality exists for single pages, and I'm going to do some digging to see if it can be done for PageType icons.
glockops replied on at Permalink Reply
glockops
aghouseh replied on at Permalink Reply
aghouseh
That's actually just for the dashboard "menu". It does not effect the Sitemap tree at all.
aghouseh replied on at Permalink Reply
aghouseh
There's an AWESOME on_page_get_icon event that is fired via the sitemap that I was able to hook into for returning the URL of a page icon. It passes the page object to your method, so you can run getCollectionTypeHandle() to determine which icon to return.
aghouseh replied on at Permalink Reply
aghouseh
This goes within your package controller (or wherever):

public function on_start(){
   Events::extend(
      'on_page_get_icon',
      'getPageData',
      'getPageIcon',
      DIRNAME_PACKAGES . '/' . $this->pkgHandle . '/models/get_page_data.php'
   );
}


Then your /packages/package_name/models/get_page_data.php has this
class getPageData {
   function getPageIcon($page){
      $theme = PageTheme::getByHandle('my_theme');
      $icon = '/img/' . $page->getCollectionTypeHandle() . '.png';
      return (file_exists($theme->getThemeDirectory() . $icon)) ? $theme->getThemeURL() . $icon : false;
   }
}
farmingSkill replied on at Permalink Reply
farmingSkill
Hello, Andrew

This is exactly what I was looking for! Would you be so kind to guide me how to set this, if I'm not using a package? Thank you for your time.