diff --git a/fc.module b/fc.module index aa97205..6335539 100644 --- a/fc.module +++ b/fc.module @@ -392,9 +392,17 @@ function fc_get_page_entity($entity_type) { else { // Figure out the URL structure, build a dummy entity // then fetch its URL. - $dummy = (object) array( + + $bundles = array_keys($entity_info['bundles']); + + $dummy_values = array( $entity_info['entity keys']['id'] => 0, + // Bundle is required for entities that require a bundle in their uri callback. + $entity_info['entity keys']['bundle'] => end($bundles), ); + + $dummy = entity_create($entity_type, $dummy_values); + $uri = $entity_info['uri callback']($dummy); $path = explode('/', $uri['path']); @@ -405,8 +413,9 @@ function fc_get_page_entity($entity_type) { } } - // Get the actual entity for this page - $entity = menu_get_object($entity_type, $pos); + // Load actual entity using the entity ID from URL. + $entity_loaded = entity_load($entity_type, array(arg($pos))); + $entity = reset($entity_loaded); } return $entity; } diff --git a/fc_progress/fc_progress.blocks.inc b/fc_progress/fc_progress.blocks.inc index e685cd5..a9ad2fb 100644 --- a/fc_progress/fc_progress.blocks.inc +++ b/fc_progress/fc_progress.blocks.inc @@ -16,8 +16,21 @@ function _fc_progress_block_view($entity_type) { } $entity_info = entity_get_info($entity_type); + // Try to get label from entity's defined label in entity keys. + if (property_exists($entity, $entity_info['entity keys']['label'])) { + $title = $entity->{$entity_info['entity keys']['label']}; + } + // Try a simple title property if exists- in the case of ECK. + elseif (property_exists($entity, 'title')) { + $title = $entity->title; + } + // At a loss so use the entity type name. + else { + $title = $entity_info['label']; + } + return array( - 'subject' => t('@title Progress', array('@title' => $entity->{$entity_info['entity keys']['label']})), + 'subject' => t('@title Progress', array('@title' => $title)), 'content' => array( 'bar' => array( '#theme' => 'fc_progress_bar',