theresa7064
theresa7064

I found I could use this to produce the page title: {{ this.page.title }} - is there something similar I can use to produce the parent page title? And can you tell me where I would find these variable names?

thanks, Theresa

daftspunk
daftspunk

{{ this.page.parent.title }} ?

theresa7064
theresa7064

I tried that, didn't work. I'm trying to make simple breadcrumbs (the plugin gave me errors i could never fix)

    <div class="breadcrumbs">
        <div class="container">
            <h1 class="pull-left">{{ this.page.title }}</h1>
            <ul class="pull-right breadcrumb">
                <li><a href="/">Home</a></li>
                <li><a href="">Plants</a></li>
                <li><a href="">{{ this.page.parent.title }}</a></li>
                <li class="active">{{ this.page.title }}</li>
            </ul>
        </div>
    </div><!--/breadcrumbs-->
    <!--=== End Breadcrumbs ===-->
jeremy23848
jeremy23848

This thread is old but no solution was provided. This is what I ended up doing to get the parent page title.

{% set parent = page.getParent() %}
{{ parent.title }}
Dizoo
Dizoo

For those who still stumble upon this post. I have created a plugin that does an attempt at generating breadcrumbs Page Headers.

What I ended up doing was this:

{% if this.page.url matches '{^\/[^/]([^/]+)\/}' %}
    {% set pages = this.page.url|split('/') %}
    {% for subpage in pages %}
        {% if not loop.first and not loop.last %}
            {% if subpage|page %}
            {% set title = subpage|capitalize|replace({'-': "", '_': " "}) %}
            <li><a href="{{ subpage|page }}">{{ title }}</a></li>
            {% endif %}
        {% endif %}
    {% endfor %}
{% endif %}

It does the following:

  • Check if the current url contains something like this WEBSITE/parent/page
  • if 2 slashes are found it will loop trough all names in between the slashes
  • In the loop it checks if the value matches any pageid
  • If yes it prettifies the value and creates a link and title to that page.

For this to properly work it is needed that the pageid of the parent is equal to the set url but in most scenario's this should be the case.

1-5 of 5