Jump to content

How to prevent hook ProcessPageListRender::getPageLabel in pagelistselect field ?


bernhard
 Share

Recommended Posts

I'm using PageHitCounter module by @David Karich

The problem is that the page hit labels show up in my pagelistselect and when I select a page, the label of that page is "123 My Page" instead of "My Page" (where 123 is the page hit count).

PHC attaches a hook to getPageLabel so I wonder if there is a way to determine if the render happens inside a pagelistselect field or not.

$this->addHookAfter('ProcessPageListRender::getPageLabel', $this, 'addPageListHitCounter');

oxtlpxR.png

Doing it via CSS does not work unfortunately, because I can hide the hit counter in the page tree, but selecting the page will show the count nevertheless because it is using js text() which does not take the display:none into account I guess.

Any ideas?

Link to comment
Share on other sites

 if($this->showForBackend) {
                $this->addHookBefore('ProcessPageList::execute', function ($event) {
					wire('config')->styles->add($this->config->urls->PageHitCounter . 'PageHitCounter.min.css');
					if($this->wire('input')->get('mode') != 'select') {
						$this->addHookAfter('ProcessPageListRender::getPageLabel', $this, 'addPageListHitCounter');
					}
				});
            }

 

  • Like 2
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...