In admin/config/search/path/patterns we currently don't have the countries available to change the path alias.
It is currently
country/[iso2] and we would like to add a pattern with pathalias to use
countries/[countryname]

CommentFileSizeAuthor
#4 make_countries-2464325-4.patch595 bytesclemens.tolboom

Comments

alan d.’s picture

Related:

https://www.drupal.org/project/pathauto_entity
#1330546: Pathauto should work with all entity types

If pathauto entity works, there is probably nothing required here :)

clemens.tolboom’s picture

Assigned: Unassigned » alan d.

The countries do not appear on http://drupal.d7/admin/config/search/path/entities

countries.module needs this patch #2472397: Add country uri to entity info

Hope Alan finds some time to review so assigning :p

alan d.’s picture

hehe: I see an entity alter is needed here too (bypassing the need for token)

/**
 * Implements hook_entity_info_alter().
 */
function country_pages_entity_info_alter(&$entity_info) {
  $entity_info['country']['uri callback'] = 'country_pages_uri';
}

/**
 * Implements callback_entity_info_uri().
 */
function country_pages_uri($country) {
  return array(
    'path' => 'country/' . $country->iso2, // Codes not open in front of me... iso2 or cid?
  );
}

clemens.tolboom’s picture

Assigned: alan d. » clemens.tolboom
Status: Active » Needs review
StatusFileSize
new595 bytes

Thanks for the quick reply. I tried the uri first but thought token is better as it is about using tokens. OTOH I'm interested in rest. And entity_info_alter was doable for this module. But why not add it to countries module?

I'm fine with doing it in this module :-)

Attached patch uses $country->iso2

clemens.tolboom’s picture

+++ b/country_page.module
@@ -35,6 +35,21 @@ function country_page_menu() {
+    'path' => 'country/' . $country->iso2,

Just a note: both iso2 as cid are accepted as ID

alan d.’s picture

Version: » 7.x-1.x-dev

Since countries doesn't have a front end page view, this is actually the perfect place for this functionality. The token value is icing on the cake for other purposes (whatever these actually are).

webflo’s picture

webflo’s picture

clemens.tolboom’s picture

Assigned: clemens.tolboom » Unassigned
alan d.’s picture

This should be safe to commit if path auto still works without the token patch in the countries queue. :)

No local environment to test myself.

clemens.tolboom’s picture

Status: Needs review » Fixed

This patch somehow slipped away. I've tested this on a site and it works as advertised.

Status: Fixed » Closed (fixed)

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