Jump to content

Recommended Posts

Posted

I am working on the backend structure that will contain the data for the finished website. I have already collected data via a number of pages and sub-pages all created successfully with their corresponding templates. I have just added a new page under 'home' with a sample sub-page but when I went to apply the template I wanted to that page it was not visible in the 'settings' dropdown list. The content of this list seems to vary depending on where you are on the tree. The 'home' page has all the templates listed. What is it that determines which template can be used on any particular page and how can I access the template I need?

Posted

Go to to a Setup > Templates. Pick a template, open Family tab, you'll see the list of allowed templates there

image.thumb.png.2e87de0277d0b7d02abf85486cbd4d5f.png

  • Like 1
Posted

Many thanks Abdus - I have just checked through all my 'family' settings and they appear to be correct. if I select home->edit->settings->template I can see all my templates. If I want to create a new page under 'home' and select home->new->templates I am restricted to just the templates on the existing top level pages. Interestingly I put some pages into 'trash' and this allowed me to select any template but would not allow me to restore the pages. 

I don't know whether something has been corrupted or I have missed some steps somewhere.

I am using ProcessWire 3.0.62

Thanks again, Michael.

Posted

Ok, I've checked out the source. It could also be a permission issue. Check if you changed access settings for a role.image.thumb.png.e48fc8b12591411d17abce5e7a0067c3.png
 

 

// ProcessPageAdd.module
/**
 * Returns an array of templates that are allowed to be used here
 *
 */
protected function ___getAllowedTemplates($parent = null)
{
    // ...
    $templates = [];
    // ...
    foreach ($allTemplates as $t) {
        if ($t->noParents == -1) {
            // only 1 of this type allowed
            if ($t->getNumPages() > 0) continue;
        } elseif ($t->noParents) {
            continue;
        }
        if ($t->useRoles && !$user->hasPermission('page-create', $t)) continue;
        if (!$t->useRoles && !$parentEditable) continue;
        if (!$t->useRoles && !$user->hasPermission('page-create', $parent)) continue;

        if (count($allParents) == 1) {
            if (count($parent->template->childTemplates)) {
                // check that this template is allowed by the defined parent
                if (!in_array($t->id, $parent->template->childTemplates)) continue;
            }
        }

        if (count($t->parentTemplates)) {
            // this template is only allowed for certain parents
            // ...
        }

        // ...
        $templates[$t->id] = $t;
    }

    // ...

    $this->allowedTemplates = $templates;

    return $templates;
}

 

Posted

Thanks Abdus, I checked all the permissions but could not identify any changes.

However, when I said I had checked all the page 'family' settings I had omitted to check the 'home' page. When I did I found a list of 'allowed' templates which excluded the one I was trying to add. I have added it and all is OK - at least to that stage!

With your advice I now have a better understanding of how this template process works - much appreciated.

Many thanks, Michael (79 years young)

  • Like 2

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...