Active
Project:
Facet API
Version:
7.x-2.x-dev
Component:
User interface
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
3 Jun 2012 at 03:29 UTC
Updated:
13 Oct 2015 at 20:19 UTC
Jump to comment: Most recent
Comments
Comment #1
cpliakas commentedNot sure you mean. Can you describe the output you are trying to achieve?
Thanks,
Chris
Comment #2
modstore commentedFor example, I have an decimal field, and when it was setup, the prefix was set to $, so I want to be able to have the facet options look like this:
$20.00 (3)
$30.00 (2)
...etc.
But currently I can't find an option to include the prefix from the field settings, so currently it looks like this:
20.00 (3)
30.00 (2)
...etc.
Comment #3
modstore commentedAfter thinking about it, I guess only the value is actually stored in the search index, so maybe I should be making this a feature request to include a couple of fields in the facet display settings of prefix and suffix.
Comment #4
cpliakas commentedI get it now. Thanks for explaining in detail.
This is a good feature request to me. The per-facet prefix / suffix options might be a good route to take, but I am thinking there should be some option to leverage the Field API settings if the facet contains Field API data. This will take a little thought to do in a way that is flexible and intuitive.
As a work around for the time being, you can actually implement hook_facetapi_facet_info_alter() and change the map callback to something custom. The map callback converts the value in the index to what is displayed to the user, so you can definitely add prefixes / suffixes in your custom callback. If you want to use the Field API settings, you can work some magic and pass whatever data you need to get this in the map options array, which is passed as the second parameter to your
map callback. For working examples of map callbacks, see thefacetapi_map_*()functions in facetapi.callbacks.inc.Thanks for posting,
Chris
Comment #5
modstore commentedThanks Chris,
Yep, I have implemented hook_facetapi_facet_info_alter() before, so will do the same again, at least until there is another option.
Cheers.
Comment #6
cpliakas commentedI am going to punt this to the 2.x branch, unless someone wants to post a patch to add this which I would very willingly accept.
Comment #7
blitux commentedHello There,
I've implemented some basic prefix/suffix capabilities using a custom module. This is the code I've used:
This works for me, but I'm sure this code could be improved, so please do it if you can. This is the first time I've ever used the field API and I don't know if this is the proper way to solve this feature.
Cheers.
Comment #8
nkostop commentedHello,
is there any other way this could be done except from the above code?
Thanks!