Jump to content

Adding icons to the page tree


Recommended Posts

I'm looking to add an icon next to the page title in the page tree, similar to how pages in draft state (with ProDrafts) can be identified by the little paperclip icon.

image.png.76d10c32a3689930721d5a6c2f2d70a7.png

What is the best way to go about this? I tried diving through the source code of a few modules and I suspect I need to hook into 'ProcessPageListActions::getExtraActions'?

Link to comment
Share on other sites

You can use custom page classes and add a getPageListLabel() method:

It can be a problem though that this markup also ends up in the main navigation and also in page select fields.

You can hide those elements via CSS though:

// site/classes/YourPageClassPage.php

  public function getPageListLabel()
  {
    return "<span class=foo>foo</span> " . $this->title;
  }
/* /site/templates/admin.less */

.PageListPage.label .foo {
  border: 2px solid red;
}

onn3fcj.png

Another option is to use RockMigrations + MagicPages, then you can simply add "pageListLabel()" instead of "getPageListLabel()" and you'll get the modified label in the pagetree but not in the menu. This is the hook I'm using: https://github.com/baumrock/RockMigrations/blob/85c28fb97411f2af1ab3c77d3911b777d3f77ccf/MagicPages.module.php#L268-L290

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...