Hi,
I get the feeling that the ID's on the facet links are not consistent.
The goal is to highlight specific facet links using custom CSS. At the moment, I can in fact take the id (e.g. facetapi-link--147) from the facet HTML output and apply the CSS to it and it works fine. However, as soon as I select a filter, most of the ID's change. I am trying to achieve that each facet links keeps it HTML ID.
State 1 (unfiltered)
<li id="item166">
<div class="facetapi-facet facetapi-inactive">
<a href="/filter/?f[0]=kompetenz%3A439" rel="nofollow" class="facetapi-inactive" id="facetapi-link--120" title=" weltweit anwenden ">weltweit (26)</a>
</div>
</li>
State 2 (filtered)
<li id="item160">
<div class="facetapi-facet facetapi-inactive">
<a href="/filter/?f[0]=im_field_rechtsform%3A6&f[1]=kompetenz%3A439" rel="nofollow" class="facetapi-inactive" id="facetapi-link--114" title=" weltweit anwenden ">weltweit (24)</a>
</div>
</li>
I played around without the sorting options which seem to be responsible for assigning the ID (?) but didn't really get to a solution.
Best for me would be if the facet links had the taxonomy-tid added to the markup, or at least some kind of value that stays consistent throughout the search and the filtering process. Eventhough I read through the code already, I'm more on the frontend design end thus didn't really find a way to patch the code myself.
Perhaps I just missed out an option in the configuration only, though. So I appreciate any hints :-)
EDIT. The title was a little misleading, I didn't mean "distinct" but rather "consistent".
Comments
Comment #0.0
Daniel Schaefer CreditAttribution: Daniel Schaefer commentedThe title was a little misleading, I didn't mean "distinct" but rather "consistent".
Comment #1
redhatusr CreditAttribution: redhatusr commentedI have the same problem trying to add icons to facet links with css. Is there any progress on this problem?
Comment #2
redhatusr CreditAttribution: redhatusr commentedI am not programmer but I am trying to do some of programmers work in order to styling facet links (add icons etc...)
Trying to add term id as a css class to every facet links.
The term id exist in path of every facet link.
But I am not sure if the real path is in $item['#path']
The original widget_links.inc line 120
The modified widget_links.inc
What mouse hover says on firefox
http://second.virtual/collection/women?f[0]=field_frame_shape%3A77
What firebug show me
<a id="facetapi-link--29" class="facetapi-inactive" rel="nofollow" href="/collection/women?f[0]=field_frame_shape%3A77">
What $item['#path'] adds to list
-IF- we findout where is the real path we can extraxt the term id from path and add it as a class, different for every facet link.
like this example:
any ideas where is the real path in widget_links.inc ?
Comment #3
redhatusr CreditAttribution: redhatusr commentedi found the term ID inside the $item['#query'] but i don't know how to extract it
var_dump($item['#query']);
Comment #4
redhatusr CreditAttribution: redhatusr commentedthis add the tem ID to facet links when none of them are selected
Comment #5
kopeboy CreditAttribution: kopeboy commentedHi guys, thank you for the work you are doing.
I had just reopened this issue when I found this one: https://www.drupal.org/node/1020372#comment-9044645
I have a question for you: d9media said he as this kind of IDs
<li id="item166">
, which would be a good start for me, but I don't have those in my HTML..why?
Comment #6
Aivee CreditAttribution: Aivee commentedHey, I tried the code redhatusr wrote, but unfortunately it didn't output term ids in classes. The value in $termid was empty.
Anyone who tried it with success?
As someone whose coding skills are minimal, I can't really figure what's going on in the mentioned code, however this would be a really useful feature. I would like to do some css magic for facet with colors (I know they are working on fancy attributes to work with this, but I'm using images for colors).
Comment #7
cmseasy CreditAttribution: cmseasy commentedUsed #4 succesfull. I am getting
<li class="leaf f1195">
in the link with f1195 as the unique taxonomy id.Comment #8
cmseasy CreditAttribution: cmseasy commentedAnd a warning when using #4:
Warning: Invalid argument supplied for foreach() in FacetapiWidgetLinks->buildListItems() (regel 126 van /home/tnportaal/domains/groeninfo.com/public_html/drupal-7/sites/all/modules/facetapi/plugins/facetapi/widget_links.inc).
That is the first foreach line in