Jump to content

Display a template icon base on date field


nghi
 Share

Recommended Posts

I was wondering how would I display an icon next to a template from the backend base on a field value? E.G date <= today

Is it possible to just do it under the advance option?

List of fields to display in the admin Page List

Link to comment
Share on other sites

You know you can now (PW 2.4) use font awesome icons with PW? E.g. "fa-search, title" in the "List of fields to display in the admin Page List" would, in the page tree, display the title and the search icon next to the pages that use that template. Is that what you are asking?

Edit:

Hmm.., reading this again, it seems you want to use custom icons?

Edited by kongondo
Link to comment
Share on other sites

You know you can now (PW 2.4) use font awesome icons with PW? E.g. "fa-search, title" in the "List of fields to display in the admin Page List" would, in the page tree, display the title and the search icon next to the pages that use that template. Is that what you are asking?

Yes kind of, I can get the font awesome icons to appear but I only want icons to appear within certain conditions.

So at first glance a user can tell if a page is being feature base on a date range. 

Link to comment
Share on other sites

You may do this by a module like that:

	public function init() {
		$this->addHookAfter('ProcessPageListRender::getPageLabel', $this, 'addPageListLabelItems');
	}

	public function addPageListLabelItems($event) {
		$page = $event->arguments('page');

		// then you do your conditionals and your styling, like for example:
		if($page->myField >= $myMinValue && $page->myField <= $myMaxValue) {
			// add your styling here
		}

		// or like that:
		if('architekt'==$page->template) {
                        // add the styling here
			$styleItem = $page->ortarchitekt == '' ? ' <span class="jhpPageListItemEmpty"><strong style="color:white">kein Ort eingetragen</strong></span> ' : '';
                        // now add the new style item to the existing output
			$event->return = $event->return . $styleItem;
		}
	}

This way I get outputs like that:post-1041-0-98815000-1392912590_thumb.jppost-1041-0-58910000-1392912592_thumb.jp

EDIT: Ah, have found it: here is a module from Soma: http://modules.processwire.com/modules/page-list-image-label/

that adds a Thumbnail to the list. That was the startingpoint for my customized PagetreeList.

If you are not (yet) familiar with modules please have a look to the HelloWorld-Module or ask here for further assistance :)

Edited by horst
  • Like 8
Link to comment
Share on other sites

  • 1 year later...

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...