summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbtopro2013-10-25 05:34:44 (GMT)
committer btopro2013-10-25 05:34:44 (GMT)
commiteb959353781c079889dd86ce297e67f7916a1f61 (patch)
tree9a6355b637f78e92d5cb89f465b431fab47f47a2
parent5c4dc9c6badea9d83d9622aa0de07f47c6e42db1 (diff)
better title handling across entities
-rw-r--r--modules/cis_shortcodes/cis_shortcodes.module13
1 files changed, 12 insertions, 1 deletions
diff --git a/modules/cis_shortcodes/cis_shortcodes.module b/modules/cis_shortcodes/cis_shortcodes.module
index 353c8c1..8e2cc1a 100644
--- a/modules/cis_shortcodes/cis_shortcodes.module
+++ b/modules/cis_shortcodes/cis_shortcodes.module
@@ -8,6 +8,17 @@ function cis_shortcodes_entity_view($entity, $type, $view_mode, $langcode) {
$links = array();
// only add embed methods on full view with access
if ($view_mode == 'full' && user_access('view cis shortcode')) {
+ // pick a nice default title for common entity types
+ $title = '';
+ switch($type) {
+ case 'node':
+ $title = $entity->title;
+ break;
+ case 'user':
+ case 'taxonomy_term':
+ $title = $entity->name;
+ break;
+ }
// load info so we know what the key id is
$type_info = entity_get_info($type);
// build properties array for rendering
@@ -36,7 +47,7 @@ function cis_shortcodes_entity_view($entity, $type, $view_mode, $langcode) {
if (isset($entity->{$fname}) && isset($entity->{$fname}['und'][0]['uri'])) {
$properties['field'] = $fname;
if ($type == 'node') {
- $properties['text'] = t('Download @title', array('@title' => $entity->title));
+ $properties['text'] = t('Download @title', array('@title' => $title));
}
else {
$properties['text'] = t('Download');