/** * Returns the parent tag collection items in list * * @param FTL_Binding $tag * * @return string */ public static function tag_list(FTL_Binding $tag) { // Stop is already processed if ($tag->getParent()->get('__loop__') === FALSE) { return ''; } $data = array(); // Collection to consider : parent tag name $collection_name = $tag->getParentName(); $collection = $tag->get($collection_name); // HTML Separator of each collection item $separator = $tag->getAttribute('separator', ', '); if (!empty($collection)) { // Create one HTML A element, pointing to the element item URL, if any. $link = $tag->getAttribute('link', FALSE); // Field to return for each collection item. $key = $tag->getAttribute('key', 'title'); // Child tag : HTML tag for each collection item $child_tag = $tag->getAttribute('child-tag'); $child_class = $tag->getAttribute('child-class'); // Separator attribute is not compatible with child-tag if (!is_null($child_tag)) { $separator = FALSE; } // Build the anchor array foreach ($collection as $item) { // Return something if the item key exists if (isset($item[$key])) { $value = $item[$key]; if ($link == TRUE && isset($item['url'])) { $value = anchor($item['url'], $value); } if (!is_null($child_tag)) { // Replace the class and tag by the child tag & class $html_tag = $tag->getAttribute('tag'); $html_class = $tag->getAttribute('class'); $tag->setAttribute('tag', $child_tag); $tag->setAttribute('class', $child_class); // Process the child rendering $value = self::wrap($tag, $value); // Restore the tag & class for parent $tag->setAttribute('tag', $html_tag); $tag->setAttribute('class', $html_class); } $data[] = $value; } } } // Lock loop $tag->getParent()->set('__loop__', FALSE); return self::output_value($tag, implode($separator, $data)); }