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

Default template based on the template of the parent page #4922

Open
cirykpopeye opened this issue Nov 28, 2019 · 6 comments · May be fixed by #5337
Open

Default template based on the template of the parent page #4922

cirykpopeye opened this issue Nov 28, 2019 · 6 comments · May be fixed by #5337
Labels
Feature New functionality not yet included in Sulu

Comments

@cirykpopeye
Copy link

Q A
Bug? no
New Feature? yes
Sulu Version 2.0.2
Browser Version any

Actual Behavior

When creating a new child-page, the template that's chosen by default almost never corresponds with the one you'll be using.

Expected Behavior

Having the option to define in your parent template what the default template should be for your new child page.

Steps to Reproduce

F.e. you have the artists page on the demo, if you add a page underneath it will most likely only be of type artist.

Possible Solutions

In a template, have an option to specify the child template. That template will then be used when creating a child on that page.

@danrot
Copy link
Contributor

danrot commented Dec 2, 2019

That sounds interesting. Can you maybe add an example how this configuration would look like in your opinion?

@cirykpopeye
Copy link
Author

cirykpopeye commented Dec 3, 2019

<?xml version="1.0" ?>
<template xmlns="http://schemas.sulu.io/template/template"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://schemas.sulu.io/template/template http://schemas.sulu.io/template/template-1.0.xsd">

    <key>team</key>

    <view>pages/team</view>
    <defaultChildView>pages/member</defaultChild>
    <controller>Sulu\Bundle\WebsiteBundle\Controller\DefaultController::indexAction</controller>
    <cacheLifetime>86400</cacheLifetime>

    <meta>
        <title lang="en">Team</title>
    </meta>

    <properties>
        <property name="title" type="text_line" mandatory="true">
            <meta>
                <title lang="en">Title</title>
                <title lang="de">Titel</title>
            </meta>
            <params>
                <param name="headline" value="true"/>
            </params>

            <tag name="sulu.rlp.part"/>
        </property>

        <property name="url" type="resource_locator" mandatory="true">
            <meta>
                <title lang="en">Resourcelocator</title>
                <title lang="de">Adresse</title>
            </meta>

            <tag name="sulu.rlp"/>
        </property>

        <property name="members" type="smart_content">
            <meta>
                <title lang="en">Team members</title>
            </meta>
        </property>
    </properties>
</template>

Note the <defaultChildView> parameter. To maybe further extend you could have a filter of types.

<?xml version="1.0" ?>
<template xmlns="http://schemas.sulu.io/template/template"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://schemas.sulu.io/template/template http://schemas.sulu.io/template/template-1.0.xsd">

    <key>team</key>

    <view>pages/team</view>
    <childViews default="pages/member">
       <view>pages/member</view>
       <view>pages/default</view>
    </childViews>
    <controller>Sulu\Bundle\WebsiteBundle\Controller\DefaultController::indexAction</controller>
    <cacheLifetime>86400</cacheLifetime>

    <meta>
        <title lang="en">Team</title>
    </meta>

    <properties>
        <property name="title" type="text_line" mandatory="true">
            <meta>
                <title lang="en">Title</title>
                <title lang="de">Titel</title>
            </meta>
            <params>
                <param name="headline" value="true"/>
            </params>

            <tag name="sulu.rlp.part"/>
        </property>

        <property name="url" type="resource_locator" mandatory="true">
            <meta>
                <title lang="en">Resourcelocator</title>
                <title lang="de">Adresse</title>
            </meta>

            <tag name="sulu.rlp"/>
        </property>

        <property name="members" type="smart_content">
            <meta>
                <title lang="en">Team members</title>
            </meta>
        </property>
    </properties>
</template>

Note the childViews, it has a param default, which would be the function I'd need, and for deeper configuration you could indeed filter on the possible templates that can be used. In this example, the default will be pages/member, but both pages/member and pages/default can be used.

@danrot danrot added the Feature New functionality not yet included in Sulu label Dec 10, 2019
@danrot
Copy link
Contributor

danrot commented Dec 10, 2019

I think we would rather name that tag childTemplates, because view would just be the twig template (or at least the already existing view is referring to the twig template).

@sulu/core-team WDYT? Is that something we should support? How would you name that XML node?

@cirykpopeye
Copy link
Author

@danrot Fair point, childTemplates would be a better name for it.

@danrot
Copy link
Contributor

danrot commented Dec 13, 2019

I have discussed with @chirimoya, @alexander-schranz and @nnatter, and we've decided that this setting would make more sense in the webspace xml, because then you have all default templates at the same place. We imagined it to look something like this:

<?xml version="1.0" encoding="utf-8"?>
<webspace xmlns="http://schemas.sulu.io/webspace/webspace"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://schemas.sulu.io/webspace/webspace http://schemas.sulu.io/webspace/webspace-1.1.xsd">

    <name>Example</name>
    <key>example</key>

    <default-templates>
        <default-template type="page" parent-template="team">member</default-template>
    </default-templates>
</webspace>

However, it would be very important that existing installations don't break because of that change (that might not be a problem of the XML, but of the representation of the XML in PHP).

@danrot
Copy link
Contributor

danrot commented Dec 13, 2019

The other thing you have mentioned (restricting the child templates) is actually the same issue as #913. However, we have shortly discussed that, and concluded that introducing a feature like this would complicate a lot of things. Also see my comment on the other issue.

And I would not worry that these two features get in the way of each other, since I would see this kind of preferred templates in the template XML anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature New functionality not yet included in Sulu
Projects
None yet
2 participants