Since the Countries module supports the Country Icons module, I am wondering how to add the country icon before the country name (within the Name column) to the the administrative table of countries at admin/config/regional/countries.

Maybe adding a new field of type Computed could be a start?

That would be a nice addition to the module. Thanks for giving hints.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Alan D.’s picture

Status: Active » Fixed

You may be able to do this by overriding the system path with an admin display on that system path using View, VBO and Admin views.

Let me know how you get on!

However, trying to make things leaner, so unlikely to integrate this directly into the module.

roball’s picture

Thanks for your suggestion.

I want to try to just add an additional field to the existing pre-defined ones (let's say the field called field_countries_country_icon). Is it possible to instruct the module to show that field in the table of countries?

Alan D.’s picture

No just the core properties, see the readme for an example.

This is an example view that will override the admin listing. You will need the patch in #1225632: Integrate with VBO (allowing custom views and bulk update options) from the latest commit to provide operations to work with (view field operations needs to be edited post applying and a full cache flush), http://drupalcode.org/project/countries.git/patch/124ef0e, or the listed patch in #6 that would provide both the view and operations in one hit.

roball’s picture

Status: Fixed » Needs review

I have applied the patch http://drupalcode.org/project/countries.git/patch/124ef0, installed Views Bulk Operations (VBO) 7.x-3.1 and flushed all caches.

After pasting the view code https://drupal.org/files/countries-view-system-override.txt into admin/structure/views/import and hitting the [ Import ] button, the following error message is displayed:

Display plugin system is not available.
Unable to import view.

Have you been able to successfully import that view?

roball’s picture

Status: Needs review » Needs work

Correcting status.

Alan D.’s picture

You need admin views too - https://drupal.org/project/admin_views

roball’s picture

Status: Active » Fixed
FileSize
8.7 KB

Thanks - after installing Administration Views the import of your above attached view code worked fine.

I have improved the view to look more similar than the module's orginal countries admin page, including sortable columns and links to each country edit page. If others want to try this as well, the views code to be imported is attached here.

The only thing I could not manage is creating a "delete" link to the deletable countries, such as Bonaire, Sint Eustatius and Saba (BQ).

EDIT: At comment #11 below I have attached a further more improved view code.

roball’s picture

Status: Needs work » Fixed
FileSize
180.66 KB

FYI, I have now managed to do this. It looks really nice. The attached screen print shows how the complete views table looks. Thanks for your help.

Status: Fixed » Closed (fixed)

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

Alan D.’s picture

Robert, if you are still listening to this thread, can you let me know how you went about adding the icon to the view here: #2070267: Provide Country Flag views field handler..

Personally can not see an easy way without inserting some PHP somewhere ;)

roball’s picture

Status: Closed (fixed) » Active
FileSize
9.71 KB

Dear Alan, sure, I'm still subscribed to this issue, and you are right, there *is* some PHP involved in displaying the icons.

The icon is displayed as a Computed Field called field_countries_country_icon, with the following Computed Code:

$field_store = '';

$entity_field[0]['value'] = $field_store;

and the following Display Code:

if (module_exists('countryicons') && module_exists('countryicons_shiny')) {
  $iso2 = $entity->iso2;
  $field_print = theme('countryicons_icon', array(
    'code' => $iso2,
    'iconset' => 'shiny',
    'title' => $iso2,
    'display_unknown' => TRUE,
  ));
// Alternatively print the icons using sprite technology:
//  $field_print = theme('countryicons_icon_sprite', array(
//    'code' => $iso2,
//    'iconset' => 'shiny',
//  ));
}
else {
  $field_print = '';
}

$display_output = $field_print;

Once you have defined this field, the countries view can be imported as the attached view code.

Hope this helped.

Alan D.’s picture

Thanks. I'll keep this one closed and work on better country flags integration in the other issue. :)

Status: Fixed » Closed (fixed)

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