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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

johnv’s picture

You 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.

rickvug’s picture

Agreed 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".

Panels context

Alan D.’s picture

if 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.

jelo’s picture

I 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:

  • argument input in the view pane configuration: from context. Then I can choose NODE: country reference field or COUNTRY: ISO alpha-2 code. However, both options don't work.
  • argument input in the view pane configuration: panel argument. Does not work.
  • contextual filter: I used the country reference field (which I think expects the ISO2 code?). In the pane preview it works with the ISO2 code, but I cannot get it to appear in the panel page. This makes me question if any content gets passed at all from the panel to the pane.

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?

Alan D.’s picture

Status: Active » Fixed

Pushed 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

rickvug’s picture

@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.

Alan D.’s picture

Cheers. Actually piggy backs on the entity:TYPE of CTools so not much to it ;)

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.