Skip to content

Commit

Permalink
Merge branch 'release/1.4.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
rhukster committed Jan 6, 2025
2 parents 24ecd56 + b218c73 commit 1a3198a
Show file tree
Hide file tree
Showing 17 changed files with 645 additions and 78 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# v1.4.0
## 01/06/2025

1. [](#new)
* PHP 8.4 compatibility support
* Added ability for page descendant taxonomy [#31](https://github.com/getgrav/grav-plugin-taxonomylist/pull/31)

# v1.3.6
## 04/16/2024

Expand Down
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,25 +46,29 @@ The plugin provides a Twig template that you need to include in your theme. Some

Where `my_url` is the URL to link to where the collection can be filtered (e.g. `/blog`) and the `taxonomy` points to a specific taxonomy type to display (e.g. `tag`). This will display all tags throughout your site

## Child-only Include
## Child-only or Descendants Include

You can also include pass an optional parameter that will show taxonomy for child-pages only:
You can also include pass an optional `true` parameter that will show taxonomy for child-pages only, or `false` for descendants:

```twig
{% include 'partials/taxonomylist.html.twig' with {base_url: my_url, taxonomy: 'tag', children_only: true} %}
```
### Show all page's descendants taxonomies
```twig
//children_only set to false
{% include 'partials/taxonomylist.html.twig' with {base_url: my_url, taxonomy: 'tag', children_only: false} %}
```
### Show specific page's descendants taxonomies

When using `children_only`, another optional parameter (`of_page`) may be used to specify the page to use:

```twig
{% include 'partials/taxonomylist.html.twig' with {base_url: my_url, taxonomy: 'tag', children_only: true, of_page: page.parent} %}
```


> NOTE: If you want to see this plugin in action, have a look at our [Blog Site Skeleton](https://github.com/getgrav/grav-skeleton-blog-site/archive/master.zip)


# Config Defaults
```
route: '/blog'
Expand Down
2 changes: 1 addition & 1 deletion blueprints.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Taxonomy List
type: plugin
slug: taxonomylist
version: 1.3.6
version: 1.4.0
description: "With the **TaxonomyList plugin** you can easily create list of **taxonomy** items such as **tags**, **categories**, etc."
icon: tag
author:
Expand Down
15 changes: 9 additions & 6 deletions classes/taxonomylist.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,14 @@ public function get()
*
* @return array
*/
public function getChildPagesTags(PageInterface $current = null)
public function getChildPagesTags(?PageInterface $page = null, bool $child_only = true, array $taxonomies= [])
{
/** @var PageInterface $current */
if (null === $current) {
$current = Grav::instance()['page'];
/** @var PageInterface $page */
if (null === $page) {
$page = Grav::instance()['page'];
}

$taxonomies = [];
foreach ($current->children()->published() as $child) {
foreach ($page->children()->published() as $child) {
if (!$child->isPage()) {
continue;
}
Expand All @@ -56,8 +55,12 @@ public function getChildPagesTags(PageInterface $current = null)
}
}
}
if(!$child_only && $child->children()->count() > 0) {
$taxonomies = $this->getChildPagesTags($child, $child_only, $taxonomies);
}
}
}
array_multisort($taxonomies);

return $taxonomies;
}
Expand Down
7 changes: 4 additions & 3 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion templates/partials/taxonomylist.html.twig
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% set taxlist = children_only is defined ? taxonomylist.getChildPagesTags(of_page) : taxonomylist.get() %}
{% set taxlist = children_only is defined ? taxonomylist.getChildPagesTags(of_page, children_only) : taxonomylist.get() %}

{% if taxlist %}
<span class="tags">
Expand Down
18 changes: 18 additions & 0 deletions vendor/autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,24 @@

// autoload.php @generated by Composer

if (PHP_VERSION_ID < 50600) {
if (!headers_sent()) {
header('HTTP/1.1 500 Internal Server Error');
}
$err = 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
if (!ini_get('display_errors')) {
if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
fwrite(STDERR, $err);
} elseif (!headers_sent()) {
echo $err;
}
}
trigger_error(
$err,
E_USER_ERROR
);
}

require_once __DIR__ . '/composer/autoload_real.php';

return ComposerAutoloaderInite611d11e84f56d74cb80353137f35dff::getLoader();
Loading

0 comments on commit 1a3198a

Please sign in to comment.