spackmat Posted January 7, 2019 Posted January 7, 2019 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?
Zeka Posted January 7, 2019 Posted January 7, 2019 $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; } }); 6 1
spackmat Posted January 10, 2019 Author Posted January 10, 2019 Great, thank you @Zeka, plain and simple!
spackmat Posted February 4, 2019 Author Posted February 4, 2019 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?
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now