- Merge request !34Issue #2854585: Improve icon selection in paragraphs type form. → (Open) created by dieterholvoet
- last update
over 1 year ago 180 pass - 🇩🇪Germany hctom
The patch from #17 misses a lot of code changes from #10, therefore hiding it. The MR diff contains all the code changes from #10 and also fixes the deprecated usage of
file_create_url()
. You should use the MR and its diff instead. - Open on Drupal.org →Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7last update
over 1 year ago Not currently mergeable. - last update
over 1 year ago 180 pass - 🇩🇪Germany stborchert
I rebased branch 2854585-improve-icon-selection with 8.x-1.x and improved the calls to
file_create_url()
resp. the file_url_generator service. - Open on Drupal.org →Core: 10.1.4 + Environment: PHP 8.1 & MariaDB 10.3.22last update
about 1 year ago Not currently mergeable. - 🇩🇪Germany hctom
Just found a small bug with this patch: The following element is added to
ParagraphsTypeForm::form()
method's form array by this patch:<?php $form['static_icon_file']['description'] = [ '#type' => 'item', '#description' => $description, ];
Unfortunately an element with
'#type' => 'item'
is treated as an input value and thus interferes with the form's actualdescription
form field value.So my changes add
'#input' => FALSE
to the new$form['static_icon_file']['description']
element to NOT treat this element as a form value anymore. - 🇨🇦Canada teknocat
I'd really like a way to set icons that don't have to be uploaded and stored in the files directory. It would be ideal to be able to just specify a path to an icon, so it could be included with the theme. I would also like the option of using something like fontawesome to provide icons, so being able to just put in an HTML tag that displays an icon would be great. Then it's on me to make sure that the icon font is included with the admin theme for the sites I build, which I already do and use in other areas.
- 🇩🇪Germany stborchert
@teknocat Hi. Did you had a change to test the merge request we've made?
After applying the changes you are able to implementhook_paragraphs_type_static_icon_uri_alter()
(in a module or theme) where you can set the icon path to wherever you want. The file could be saved in a module, in the a theme, on an external storage, you name it ...To use icons provided by fontawesome, you'll nee to override/decorate the
ParagraphsTypeListBuilder
class and change the way,$row['icon_file']['data']
is build.
Example (not tested):<?php $row['icon_file']['data'] = [ '#theme' => 'html_tag', '#tag' => 'span', '#attributes' => [ 'class' => ['fa-' . $entity->id()], ] ]; ?>
This will create a
<span>
tag using the paragraph type ID as fontawesome class. - 🇨🇦Canada teknocat
@stborchert ah ok! Sorry I don't think I fully understood the possibilities with that merge request.
I'll try that out.