Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Add an additional template on top of facets_result_item
for wrapping of those results. See #12
Comment | File | Size | Author |
---|---|---|---|
#16 | add_template-2796143-16.patch | 4.83 KB | shkiper |
Comments
Comment #2
borisson_That sounds like a good idea, no idea how to go about it, but it sounds good.
Comment #3
johnwebdev CreditAttribution: johnwebdev commentedInstead of the plugin returning a item_list, it should instead return another template that wraps the item_list. This allows us to override the wrapper template.
Comment #4
borisson_@johndevman, that sounds like a solution, not sure if it's a good solution though. It'd be great to have an opinion of a front-end type person about this.
However this doesn't really fix the specific problem in the IS.
Comment #5
johnwebdev CreditAttribution: johnwebdev commentedI did some quick drawing:
http://i.imgur.com/EhjFNFQ.png
By having a "Wrapper" template, we should be able to place a label, and then "Item list" and finally some "Reset button". The Reset button could perhaps be included as an item itself, as in the the issue "All links". Not sure.
The Item list could be anything, perhaps a
<select>
or, if we just listed as links a<ul>
. The item could pretty much remain the same, as the current template. But for this to work, each Widget would be responsible for having it's own set of templates to work with.This gives us much more flexibility as a front-end developer and we can more or less remove most of the JavaScript code.
So we could probably (for item list and item) get away easy by changing:
and
build()-method in the WidgetPluginBase:
which theme it uses. Perhaps by passing some data when calling the parent::build on each Widget.
$build = parent::build($facet);
Comment #6
ollu CreditAttribution: ollu commented@johndevman, looks like a nice solution and I like the idea of having template files that I can override instead of javascript.
Comment #7
johnzzonI too like the possibility to have template files for this.
Comment #8
johnwebdev CreditAttribution: johnwebdev commentedHave there been any discussion around this one @borisson_?
Comment #9
borisson_This was planned to be discussed at last week's hangout, but we had to cancel that due to other engagements that the other maintainers had. I asked the frontend developer here at work to have a look at this issue to help decide direction - he hasn't had the time to look at this so I'll ask again. I'll send out a tweet to ask for more input on this issue.
Comment #10
StryKaizerSorry I missed the hangout, here's my POV
We can/should not allow users to theme the checkboxes using TWIG.
The reason is, checkboxes in facets are actually links (getting tranformed into checkboxes by javascript).
This is because facets does not support changing more then 1 facet at once. Therefor, every check/uncheck should always trigger a request.
Once we allow twig templates on checkboxes, we can not ensure every check/uncheck triggers a request, which breaks facets.
Also we can not ensure gracefull degration into links once javascript is disabled as we do now.
So for me, this can only implemented if we rewrite our url_processors to support multiple facet-enabling-values at once.
Comment #11
borisson_I totally forgot about this. I guess this means this issue can be closed as won't fix and we should document the reason somewhere?
Comment #12
johnwebdev CreditAttribution: johnwebdev commentedWhat if each widget are responsible if it's overridable or not? Personally I'd rather deal with those 2 issues but still having the markup control rather than not being able to do anything, or resolve things by doing ugly JavaScript/CSS-hacks.
Or we could make sure a checkbox/dropdown widget are not overridable. Either way having a wrapper template around the item list does not make any difference to these issues above. Even though we can override things with templates, we don't have to remove the JavaScript. So checkboxes template could still be links with an JavaScript "transformer".
Being able to override templates, and wrapping everything using a wrapper instead of returning an item list gives so much more flexibility. However there are room for limitation if required be.
Comment #13
borisson_We figure that a wrapping template is a good idea as a nice to have.
Comment #14
borisson_Updated IS.
Comment #15
borisson_To finish this issue we need to do the following:
hook_theme
implementation. (facets_item_list
)Comment #16
shkiper CreditAttribution: shkiper as a volunteer commentedComment #17
borisson_Same remarks as https://www.drupal.org/node/2846343#comment-12001354, great job!
Comment #18
borisson_Committed and pushed, thanks!