Jump to content

Unicode/Emoji instead of FontAwesome icons as template icons?


spackmat
 Share

Recommended Posts

Hi,

I am implementing a page with many different templates and in many cases the FontAwesome icon set has no really good/distinctive icon. We use notion.so much for planning and there we set an emoji for every entity do recognize them easily.

Question: is there any way to use unicode characters instead of FontAwesome icons for ProcessWire templates?

I saw this topic, so there is a hook for the rendering of those icons in the page tree, but how can I replace the Icon-field of a template with a simple text-input? I am not that familiar with the PW internals yet.

Any ideas on that?

 

Link to comment
Share on other sites

 

$this->addHookAfter('ProcessTemplate::buildEditForm', function ($event)
{
	$form = $event->return;
	$template = $event->arguments[0];
	$icon_field = $form->find('name=pageLabelIcon')->first();
	$icon_field->collapsed = Inputfield::collapsedHidden;

	$field = $this->modules->get('InputfieldText');
	$field->attr('id+name', 'template_emoji');
	$field->icon = 'list-ol';
	$field->attr('value', $template->template_emoji);
	$field->columnWidth = 100;

	$form->insertAfter($field, $icon_field);
	$event->return = $form;
});


$this->addHookBefore('ProcessTemplate::executeSave', function ($event)
{
	$template = $this->templates->get($this->input->post->id);
	$template->set('template_emoji', $this->input->post->template_emoji);
});

$this->addHookAfter('ProcessPageListRender::getPageLabel', function ($event) {
	$page = $event->arguments('page');
	$template =  $page->template;

	if($template->template_emoji) {
		$event->return = $template->template_emoji . ' ' . $event->return;
	}
});

420464969_2019-01-0722_12.03djytg.png.8f0af41037954d5206ceb7bbca4c6684.png

  • Like 6
  • Thanks 1
Link to comment
Share on other sites

  • 4 weeks later...

Hi everyone,

I implemented Zeka's snippet as a module and it works as expected.

But the emojis are only shown within the pagetree, not in the listings of templates, which would be really appreciated for my project as there are tens of templates for several datatypes. I looked through the core code and didn't find hooks for those listings. What is the preferred way to find core system hooks?

I saw that the icon system is deeply integrated into the core, so I am close to abandon the emoji-idea, since it looks not that easy to replace the icons everywhere. Any thoughts on that?

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