addItem(__('Home'), 'index.php'); // extract post from current URL $id = url_to_postid(JUri::current()); $post = get_post($id); if ($post) { $tree = array($post); // get post parent $post->post_parent; // iterate as long as we have a parent ID while ($post && $post->post_parent) { // get parent $post = get_post($post->post_parent); if ($post) { // prepend parent array_unshift($tree, $post); } } // get regex to extract shortcodes from post content $regex = get_shortcode_regex(); // build tree foreach ($tree as $post) { $parts = array(); if (preg_match("/$regex/s", $post->post_content, $match)) { // search for the component name if (isset($match[2])) { $parts['option'] = 'com_' . $match[2]; } // search for shortcode attributes if (isset($match[3])) { // extract key and values from shortcode attributes if (preg_match_all("/([a-z0-9_\-]+)=\"([^\"]*)\"/si", $match[3], $chunks)) { // iterate chunks for ($i = 0; $i < count($chunks[0]); $i++) { // append key=val to $parts $parts[trim($chunks[1][$i])] = $chunks[2][$i]; } } } } // build plain link $link = 'index.php?' . http_build_query(array_filter($parts)); // add post within the pathway $this->addItem($post->post_title, $link); } } } }