Lets allow to add classes for list item and link item in the facet.

I.e. in FacetapiWidgetLinks::buildListItems() use key $item['#attributes']['class'] to set class for the links and $item['#list_attributes']['class'] to set class for list item.

This is very handy for theming. For example if we want to show facets as tabs we can add additional classes to links and list items.

Comments

ygerasimov’s picture

Status: Active » Needs review
StatusFileSize
new1.92 KB

See attached patch.

cpliakas’s picture

Great feature request. I think the ideas are solid, I'll try to test sometime tonight.

Thanks for the contribution,
Chris

cpliakas’s picture

So looking through the code, what steps would a themer have to take to add classes to an item?

ygerasimov’s picture

hm... yes, you are right, it is not quite possible for themer to add class for list item.

What I did was I created custom filter and there prepared facet links with needed array key (in execute() method). As don't have any possibility to "edit" each facet link, we cannot set these classes via interface.

But maybe themer should use some 'alter' hook to add classes that needed for any of the links.

cpliakas’s picture

What I am thinking is that it could be interesting to add textfields similar to Semantic Views / D7 Views that would allow for adding classes and wrapper markup via the UI. Might be an interesting non-code technique for themers to leverage. Would be curious to get your feedback on this.

ygerasimov’s picture

I think it is quite nice thing. But I don't think it is really needed as developers have quite good flexibility to create their own widgets. What I mean is that adding feature of adding classes from UI will introduce a lot of code that can be avoided with good documentation.

Of course if there will be many feature requests to do this implementation it is worth the time then.

cpliakas’s picture

Status: Needs review » Needs work

That's a good take, and thinking about this further you are probably right about giving good developers the flexibility to create widgets that do this. Let's continue to explore methods to make it easier to add classes to the list items like you original post.

Thanks for the feedback,
Chris

cpliakas’s picture

Status: Needs work » Closed (won't fix)

Marking this as "won;t resolve" due to the excellent documentation you wrote for developers to create their own widgets. Ideally I would like to have more flexibility over the theming in the default widgets, however in the spirit of getting 1.0 released I think the best approach for now is for people to create their own widgets to create more advanced displays.

Thanks for posting,
Chris

mikelaroy’s picture

Issue summary: View changes

Just assuming the documentation you're referring to is this.

Have you considered revisiting this? I'm thinking about a situation involving an existing E-commerce site using Facets where writing a custom widget may not be an option. For a themer coming into a project who is not able to create a custom widget like in the linked example, having a class on the list item would be a huge asset and save a ton of resources.