It would be very powerful to have full support for ISO identifiers as CTools Contexts, particularly within Panels. To use an example, imagine a URL path such as journey/%country_from/%country_to where based on the ISO identifiers a Panels page could house various information about the countries one is travelling between (eg. journey/CAD/POL). At the moment this is possible using country id but ISO identifiers would be preferable for URL arguments. From what I can tell, the current context integration is coming from other integrations (Entity API?) rather than purposeful effort at CTools context integration.
Any ideas here? Consider this a feature request. I have not dug into CTools context plugins so I could easily be mistaken about the technical specifics.
Comment | File | Size | Author |
---|---|---|---|
Context token replacement | 525.35 KB | rickvug | |
Panels argument context selection | 194.29 KB | rickvug | |
Context argument selector | 136.74 KB | rickvug |
Comments
Comment #1
johnvYou can verify how the 'Term ID' argument/contextual filter operates. I contains an option 'use Term name in argument', which converts the term name into the term id.
You can create an analog country argument. It shouldn't need CTools.
Comment #2
rickvug CreditAttribution: rickvug commentedAgreed that I need to take a look at how this is working technically. I noticed that "use Term name in argument" is not an option in Panels but it is available within Views. The only option here that isn't a numeric ID is "User: name".
Comment #3
Alan D. CreditAttribution: Alan D. commentedif you do tackle this, and if this is not linked to the entity property data, use countries_country_lookup() which should allow any country property to be used for the lookup.
path/$c1/$c2
So for Australia, $c1/$c2 could be anything including 36, "036", AUS, AU, (next two are risky if users edit the country names), "Australia" or "Commonwealth of Australia". The country cid (or uuid) would fail here.
This function works by the system guessing the property using _countries_estimate_property_type() and then it does the lookup using this. A name look-up will fall back to check the official names too if not found. As noted, names would be problematic with i18n / edits / updates, so would not be recommended.
Comment #4
jelo CreditAttribution: jelo commentedI have a related question to country support in panel contexts. Does country module provide these details to panels at all, in particular as context and not arguments? I have spent hours trying to make this work. Where do you find the screenshot from #2? I have not seen that, maybe because I am using a node template overwrite instead of a panel page which does not have a path or arguments?
I have two content types:
1) country details, includes a field referencing country (field type country). I noticed that this does not store the unique country ID in the database, but the iso2 value.
2) country data, includes a field referencing country (field type country)
I use panels with a node template overwrite for the content type country details, i.e. a user visits a country such as Brazil and gets to see all the details from that content type plus additional details from country module, e.g. flag, official name etc.
Now I tried to build a pane displaying country data that I can embed on that node overwrite page (country details) to add the statistical data I have for each country. I have tried to do following:
When I use devel to look at the loaded objects on a country details page, the country reference field is listed with the ISO2 values.
Any idea how I can get panels to work with country to use iso2 as the link between various content types that all reference a country?
Comment #5
Alan D. CreditAttribution: Alan D. commentedPushed to dev (with a million other things). This and #1458938: Add schema columns properties should really help things along here :)
Reopen if you have issues.
Examples:
countries/36
countries/036
countries/AU
countries/au
countries/Australia
Names are case sensitive, so "countries/australia" fails. I.e. Use keys / ISO codes
Comment #6
rickvug CreditAttribution: rickvug commented@Alan D. - This is awesome! The patch (http://drupalcode.org/project/countries.git/commitdiff/c25b4f3fdefc8abeb...) is simple, I guess you just need to know where to hook in. I hope to get a chance to test soon. Thanks.
Comment #7
Alan D. CreditAttribution: Alan D. commentedCheers. Actually piggy backs on the entity:TYPE of CTools so not much to it ;)