We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
It would be nice to also get the tags of the pages below. This is useful when using '@self.descendants' as item collection.
The text was updated successfully, but these errors were encountered:
I am no php expert, so the following code should be reviewed first. That is my first time hacking php. Feel free to adapt it!
/** * Get taxonomy list with only tags of the child pages. * @param bool Include also recursively descendants of the child pages. * * @return array */ public function getChildPagesTags(bool $recursive = false) { $current = Grav::instance()['page']; $taxonomies = $this->getChildPagesTagsInternal([], $current, $recursive); return $taxonomies; } /** * @internal * @param array $taxonomies * @param \Grav\Common\Page\Page $page * @return array */ protected function getChildPagesTagsInternal(array $taxonomies, \Grav\Common\Page\Page $page, bool $recursive = false) { // Also parse all sub pages if($recursive == true) { foreach ($page->children()->published() as $child) { $taxonomies = $this->getChildPagesTagsInternal($taxonomies, $child, $recursive); } } // Parse current page foreach($this->build($page->taxonomy()) as $taxonomyName => $taxonomyValue) { if (!isset($taxonomies[$taxonomyName])) { $taxonomies[$taxonomyName] = $taxonomyValue; } else { foreach ($taxonomyValue as $value => $count) { if (!isset($taxonomies[$taxonomyName][$value])) { $taxonomies[$taxonomyName][$value] = $count; } else { $taxonomies[$taxonomyName][$value] += $count; } } } } return $taxonomies; }
Sorry, something went wrong.
Successfully merging a pull request may close this issue.
It would be nice to also get the tags of the pages below. This is useful when using '@self.descendants' as item collection.
The text was updated successfully, but these errors were encountered: