<?php /** * @file views/default/object/views_counter_demo.php * @brief Displays the views counter entity with the views counter and a delete button */ if ($vars['full']) { // Just use add_views_counter() and pass the entity guid for have the views counter setted up for that entity add_views_counter($vars['entity']->guid); echo elgg_view('views_counter'); echo '<br />'; echo elgg_view('export/entity', $vars); } else { echo elgg_view('object/listing_view', $vars); }
<?php namespace AU\ViewsCounter; /** * @file views/default/views_counter/add.php * @brief Add a view counter to any elgg entity * * @uses $vars['entity'] An elgg entity which the views counter will be added * @uses $vars['entity_guid'] An elgg entity guid that may be used instead of $vars['entity'] */ $entity_guid = get_input('entity_guid') ? get_input('entity_guid') : $vars['entity']->guid; if ($entity_guid && ($vars['full_view'] || $vars['views_counter_full_view_override'])) { add_views_counter($entity_guid); }