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.
I've got a view of countries. I've got countryicons and countryicons_shiny enabled. I'm looking for a way to include a country's flag icon in my view of countries. Is that do-able? I don't see the views integration in either countries, or countryicons.
Comment | File | Size | Author |
---|---|---|---|
#13 | views_flag_field-2070267-9.patch | 3.73 KB | earelin |
#4 | example.png | 4.32 KB | Alan D. |
#4 | example-country-flag-field-selection.png | 7.17 KB | Alan D. |
#4 | example-country-flag-settings.png | 11.73 KB | Alan D. |
#3 | views_handler_field_countries_flag.inc_.txt | 2.59 KB | Alan D. |
Comments
Comment #1
Alan D. CreditAttribution: Alan D. commentedcan u supply an export of the view for me to take a look at it please
Comment #2
johnv@ezeedub, please examine the three attached printscreens, of my taxonomy view with a country field. I think this is what you mean.
Comment #3
Alan D. CreditAttribution: Alan D. commentedI think that ezeedub has an actual country view, otherwise it is fairly hard to miss the formatter options for the country field. Must be fairly easy, I walked someone through creating the view here: #2051015: How to add Country Icons to the administrative table of countries, but can not see how the icon is inserted with PHP or a custom template that runs some PHP.
One way is (quick hack and would not be the final version):
countries.info
views/countries.views.inc
and the attached file, renamed to views/views_handler_field_countries_flag.inc
Comment #4
Alan D. CreditAttribution: Alan D. commentedSimple field listing:
Producing:
Comment #5
Alan D. CreditAttribution: Alan D. commentedIn #2051015: How to add Country Icons to the administrative table of countries, that user added a computed field that stored the icon and that allowed him to render the flag just like any other field.
I'll keep this issue open for a views field handler ;)
Comment #6
roball CreditAttribution: roball commentedA views field handler implemented by the Countries module would be an awesome addition! This would no longer need the Computed Field module to be involved. Very user-friendly :-)
Comment #7
ezeedub CreditAttribution: ezeedub commented@Alan D Yes, I have a view of countries. Your solution in #3 is exactly what I was thinking. Why do you think it's temporary?
Here's a patch version. I removed the continent_code checkbox. I'm also thinking we could remove the Icon suffix here, since there are already views fields for those properties.
Comment #8
ezeedub CreditAttribution: ezeedub commentedforgot to change status
Comment #10
Alan D. CreditAttribution: Alan D. commentedBecause it duplicates a significant amount of code... This should be handled by a helper function so that both of these forms stay sync'ed ;)
Comment #11
ezeedub CreditAttribution: ezeedub commentedAh, that. Good point by you! :)
Comment #12
earelin CreditAttribution: earelin commentedI have updated the patch. Now is not using deprecated function countries_get_country and maybe is going to pass testing.
Comment #13
earelin CreditAttribution: earelin commentedError fixed in the rendering fuction
Comment #14
Alan D. CreditAttribution: Alan D. commentedNeeds review will trigger the testing (albeit that isn't that comprehensive)
Comment #17
earelin CreditAttribution: earelin commentedComment #19
earelin CreditAttribution: earelin commentedI have updated the issue to the last version, the patch is not for 2.1. Now it has passed the test.
Comment #20
roball CreditAttribution: roball commentedPatches should however always be made against the current Git branch (7.x-2.x), which corresponds to the 7.x-2.x-dev release snapshot.