Skip to content
New issue

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

v.3.2.1 sublevels not generated #27

Open
awrog opened this issue May 15, 2023 · 6 comments
Open

v.3.2.1 sublevels not generated #27

awrog opened this issue May 15, 2023 · 6 comments

Comments

@awrog
Copy link

awrog commented May 15, 2023

After updating to grav-plugin-page-toc-3.2.2.zip the sublevels of my page are no longer displayed.

grav-plugin-page-toc-3.2.1
image

grav-plugin-page-toc-3.2.2
image

markdown of page

[toc]

### Portaal

....

#### Stappenplan

### Demonstratievideo's

#### Overstappen op het portaal

....

#### Inloggen in LRP via het portaal

... 

#### Tweede / volgende rol koppelen aan portaal-account

... 

#### Gebruikersnaam (e-mail) van het portaal wijzigen

...

### Zie ook

#### Gebruikersnaam vergeten

...

#### Wachtwoord vergeten

...

#### Nieuwe telefoon

...

#### 2FA resetten

... 

#### installeren 2FA-app / authenticatie-app

... 

### Veelgestelde vragen

...

@lilian-pouliquen
Copy link
Contributor

I confirm that it is broken. Only the start level headers do show up in toc and I cannot use v3.2.1 because of broken characters issue.

@awrog
Copy link
Author

awrog commented Jul 21, 2023

@lilian-pouliquen
There is a work-around, you have to change (only) /user/plugins/page-toc/templates/components/page-toc.html.twig

v.3.2.2 starts with

{% import _self as self %}

{% macro toc_loop(items) %}
   {% for item in items %}
...

This does not work correctly (only generates one level)

v.3.2.1 starts with

{% macro toc_loop(items) %}
    {% import _self as self %}
    {% for item in items %}...

This works correctly, so you could use the version of v.3.2.1

I noticed that completely removing {% import _self as self %} also works.

{% macro toc_loop(items) %}
    {% for item in items %}
        {% set class = loop.first ? 'first' : loop.last ? 'last' : null %}
        <li {% if class %}class="{{ class }}"{% endif %}>
            <a href="{{ item.uri }}">{{ item.label }}</a>
            {% if item.children|length > 0 %}
                <ul>
                    {{ _self.toc_loop(item.children) }}
                </ul>
            {% endif %}
        </li>
    {% endfor %}
{% endmacro %}

{% if active or toc_config_var('active') %}
<div class="page-toc">
    {% set table_of_contents = toc_items(page.content) %}
    {% if table_of_contents is not empty %}
        <h4>{{ 'PLUGIN_PAGE_TOC.TABLE_OF_CONTENTS'|t }}</h4>
        <ul>
            {{ _self.toc_loop(table_of_contents.children) }}
        </ul>
    {% endif %}
</div>
{% endif %}

@lilian-pouliquen
Copy link
Contributor

@awrog
Thank you so much for your reply, I will try it on tomorrow. I will come back to let you know if it works.

Thanks again!

@lilian-pouliquen
Copy link
Contributor

@awrog
It is working like a charm! Thank you again for the workaraound.
I hope this will be fixed soon, I could not find out why this file has been changed in the commit referencing a deprecation warning.

@morvael
Copy link

morvael commented Aug 22, 2023

I have this problem with both 3.2.1 and 3.2.2

@pmoreno-rodriguez
Copy link

I confirm that it is wrong.
With code from @lilian-pouliquen it works fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants