public function hookAdminItemsShowSidebar($args) { $item = $args['item']; $html = '<div class="info panel">'; $html .= '<h4>' . __('Multiple Collections') . '</h4>'; $collections = multicollections_get_collections_for_item($item); // No collection. if (empty($collections)) { $html .= '<p>' . __('No multiple collections') . '</p>'; } else { $html .= '<ul>'; foreach ($collections as $collection) { $html .= '<li>'; $html .= __('%s [Items count: %d]', link_to_collection(null, array(), 'show', $collection), multicollections_total_items_in_collection($collection)); $html .= '</li>'; } $html .= '</ul>'; } $html .= '</div>'; echo $html; }
/** * Corresponds to regular function loop('collections', $collections). * * @see loop() * @param $item * @return */ function multicollections_loop_collections_for_item($item = null) { if (is_null($item)) { $item = get_current_record('item'); } $collections = multicollections_get_collections_for_item($item); return loop('collections', $collections); }