Comments

clemens.tolboom’s picture

Status: Active » Needs review
StatusFileSize
new952 bytes

Attached patch adds a display format.

clemens.tolboom’s picture

StatusFileSize
new924 bytes

Fixed:

+++ b/countryview.module
@@ -48,3 +48,31 @@ function countryview_view_access($country) {
\ No newline at end of file

Whitespace error

alan d.’s picture

Status: Needs review » Needs work

We should use country_property($country, 'name') or entity_label() for i18n.

We also loss a lot of the options that are provided by the base module.

If Field formatter settings API module is added as a dependency, you could actually just modify the existing widgets to link to the countries page... "Link to content".

i.e. Example usage (on any field) is Field formatter class module

Another option is to provide token based link paths back in the countries module itself, which has probably a lot more use cases:

Integration with this module:

country/[country:iso2]

A possible real example for one of our sites, Integrating with views (using contextual filters) + og

groups/[country:iso2]

Thoughts?

clemens.tolboom’s picture

Assigned: Unassigned » clemens.tolboom

@Alan D. thanks for the feedback. Will follow your leads.

clemens.tolboom’s picture

I fixed for #3

We should use country_property($country, 'name') or entity_label() for i18n.

in feature branch [edit] http://cgit.drupalcode.org/sandbox-aland-2362909/log/?h=feature/display-... [/edit].

Following https://www.drupal.org/project/field_formatter_settings next to https://www.drupal.org/project/field_formatter_class I ran into #1616426: Compatibility with Display Suite which seems to be a DS Bug still open #1875750: Allow DS core fields to have alterable settings, include them in field_info_instance_settings()
I'm testing this option still.

I like the token based path as that frees the hard coded path. Will dive into this too.

clemens.tolboom’s picture

Status: Needs work » Needs review
StatusFileSize
new2.55 KB

I followed the token route. Please review.

clemens.tolboom’s picture

StatusFileSize
new2.76 KB

I forgot token helper for widget. And changes some descriptions.

  1. +++ b/country_page.module
    @@ -48,3 +48,88 @@ function country_page_view_access($country) {
    +      '#description' => t('Label for link to country.'),
    

    Better wording.

  2. +++ b/country_page.module
    @@ -48,3 +48,88 @@ function country_page_view_access($country) {
    +      '#description' => t('You must use tokens.'),
    

    Better wording.

For changes done see feature branch http://cgit.drupalcode.org/sandbox-aland-2362909/log/?h=feature/display-...

hanno’s picture

Status: Needs review » Needs work

The link results in <a href="/name">Denmark</a>. The value in the config is country/[country:iso2], so I would expect <a href="/country/dk">Denmark</a>

clemens.tolboom’s picture

While developing I did a lot

drush registry-rebuild
drush cache-clear all

which helped to see my code changes. Maybe that helps.

hanno’s picture

Looks to me a typo in line 137:

$element[$delta] = array('#markup' => l($title, 'name'), $path);

should be something like

$element[$delta] = array('#markup' => l($title, $path));
clemens.tolboom’s picture

Status: Needs work » Needs review
StatusFileSize
new2.75 KB

@Hanno thanks for testing. Committed on feature branch.

Are you OK with the widget labels/descriptions?

alan d.’s picture

It would be better to use the popup imho.

+    if (module_exists('token')) {
+      $form['token_help'] = array(
+        '#value' => 'Browse available tokens',
+        '#theme' => 'token_tree',
+        '#token_types' => array('country'),
+        '#dialog' => TRUE,
+      );
+    }
clemens.tolboom’s picture

StatusFileSize
new2.82 KB

@Alan D. indeed way better.

Are we now RTBC ?

clemens.tolboom’s picture

StatusFileSize
new2.75 KB

Checking against the token docs https://www.drupal.org/documentation/modules/token it seems better to use

$form['token_help'] = array(
  '#theme' => 'token_tree_link',
  '#token_types' => array('country'),
);
alan d.’s picture

No worth re-rolling, but a couple things

"l($title,$path));" space after the comma

We are deep in site admin config here, but without Token and if they change the values, they could find things hard to repair.

Maybe

"Use tokens for context. i.e. country/[country:iso2]"
"Use tokens for context. i.e. [country:name]"

Happy either or

Manual code review rtbc from me :)

alan d.’s picture

i.e. one t() string 'Use tokens for context. i.e. %example' in case that wasn't obvious.

  • clemens.tolboom committed 324366a on 7.x-1.x
    Issue #2403839 by clemens.tolboom, Alan D.: field display as link
    
clemens.tolboom’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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