Template inheritance

  • Betroffene Version
    WoltLab Suite 3.1

    Hello,

    I would need a child template to fill a block in a parent template.

    This thing in smarty is possible with tag block, but when I try to use this tag on woltlab an error is returned.

    Is there a possibility of using something like this?

    Thanks for the future reply.

    EDIT: move this thread on Creating Styles

  • What I would like to do is move a part of the code of certain templates in the header.tpl to do this in many template engines you can create blocks in the fathers templates (in my case header.tpl) and fill them in the template that use the parent.

    Like block in smarty.

    Or component in blade

  • Is not the same thing.

    If I am in the articles page, I should show the title of the article.

    If I'm on the user profile page it should show me the photo of the user with the cover.

    If I am on the personal blog page you should show me more information.

    I would need to be able to dynamically include data that are present in the corresponding templates: article, user, blog.

    Without going into conflict because maybe in user we have a user object with certain parameters that in blog for example does not have.

    For example. In the user object of the template user. The method for calling up the cover image is present.

    But the user object of the blog template does not have this method and rightly gives me errors.

    Is not there a way to use a component similar to that of a smarty or blade?

    Or still find a way to load components in pageHeader based on the template we are loading?

    For example, saying include your AwesomeTemplate only if you're on the articles page?


    Thanks Alexander Ebert :)

    • Offizieller Beitrag

    Hello,

    You can query the currently active main template and decide if you need to do anything:

    Code: yourAwesomeTemplate.tpl
    {if $templateNameApplication === 'wcf' && $templateName === 'user'}
        {* User Profile *}
    {elseif $templateNameApplication === 'blog' && $templateName === 'entry'}
        {* Blog Entry *}
    {/if}

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!