Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2015-05-19 12:34:12

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: template inheritance

sacripant wrote #290921:

Ruud, can you please translate this exemple with your system ?

Sure.

<txp:rvm_inherit page="base"> <!-- I could've used 'form="base" instead here -->

<txp:rvm_block name="head-title">
   page title for author list page
</txp:rvm_block>

<txp:rvm_block name="main">
  <h1><txp:author /></h1>
  <txp:article form="author-list" limit="5" />
</txp:rvm_block>

</txp:rvm_inherit>
<html>
  <head>
    some code
    <title>
    <txp:rvm_block name="head-title"/>
    </title>
     some code   
  </head>
  <body>
    some code
    <main>
    <txp:rvm_block name="main" />
    </main>
    some code
  </body>
</html>

Note that in the ‘base’ template, I didn’t use <rvm_block> as a container tag. Normally I would, to supply a default value, in case the block contents are not modified during inheritance.

Offline

#14 2015-05-19 13:04:39

sacripant
Plugin Author
From: Rhône — France
Registered: 2008-06-01
Posts: 479
Website

Re: template inheritance

Thanks Ruud,

But what is your author-list file ? a txp page, a txp form ?
And if it’s a page, how I assign your page for work only in author context ?

Offline

#15 2015-05-19 13:11:08

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: template inheritance

It can be either a page or a form. The plugin doesn’t treat them differently. So you can let a form inherit from a page or a form and let a page inherit from a page or a form. All combinations are possible.

Offline

#16 2015-05-19 13:58:19

mrdale
Member
From: Walla Walla
Registered: 2004-11-19
Posts: 2,215
Website

Re: template inheritance

interesting… but I don’t understand how this approach is better than using <txp:output_form form="my_form">Something</txp:output_form> and <txp:yield />.

What am I missing?

Offline

#17 2015-05-19 14:11:42

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: template inheritance

It’s not better or worse. Just different.

Offline

#18 2015-05-19 14:12:40

sacripant
Plugin Author
From: Rhône — France
Registered: 2008-06-01
Posts: 479
Website

Re: template inheritance

For me, template by inheritance system is very interesting to gather all the components and contents of a context in the same code page and this independently of the layout structure.

For exemple, if for a author context you want :

  • a specific page title
  • add a specific CSS
  • add a specific content
  • add a specific JS

you can gathering all in one code page and injecting in different blocks :

<txp:rvm_block name="head-title">
   your specifique page title
</txp:rvm_block>

<txp:rvm_block name="additionnal-css">
   <link src="your additionnal-css">
</txp:rvm_block>

<txp:rvm_block name="main">
   you main content for author page
</txp:rvm_block>

<txp:rvm_block name="additional-js">
   <script src="your-additionnal-js" />
</txp:rvm_block>

Last edited by sacripant (2015-05-19 14:21:51)

Offline

#19 2015-05-19 15:24:36

etc
Developer
Registered: 2010-11-11
Posts: 5,053
Website GitHub

Re: template inheritance

I guess, things are getting interesting with parent/child attributes (provided I understand how they work). This seems not straightforward (for me) with output_form/yield/variable:

<txp:rvm_inherit page="base">
  ...
  <txp:rvm_block name="head-title">
    <txp:rvm_block name="head-title" parent="1" /> - <txp:title />
  </txp:rvm_block>
  ...
</txp:rvm_inherit>

with “base” page

<html>
  <head>
    some code
    <title>
    <txp:rvm_block name="head-title">
      <txp:site_name />
    </txp:rvm_block>
    </title>
     some code   
  </head>
  ...
</html>

It’s not a wow example, but I like “structural” tags. Ruud, why wouldn’t you post the code for testing?

Offline

#20 2015-05-19 17:15:50

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: template inheritance

  <txp:rvm_block name="head-title">
    <txp:rvm_block name="head-title" parent="1" /> - <txp:title />
  </txp:rvm_block>

Can be written as:

  <txp:rvm_block name="head-title">
    <txp:rvm_block parent="1" /> - <txp:title />
  </txp:rvm_block>

It would be trivial to create an extra tag that allows you to do this, but I’m not sure if that is needed:

  <txp:rvm_block name="head-title">
    <txp:rvm_parent /> - <txp:title />
  </txp:rvm_block>

I’ll write up some documentation and then upload the plugin code.

Offline

#21 2015-05-19 18:03:27

etc
Developer
Registered: 2010-11-11
Posts: 5,053
Website GitHub

Re: template inheritance

ruud wrote #290930:

It would be trivial to create an extra tag that allows you to do this, but I’m not sure if that is needed: <txp:rvm_parent />

I would prefer <txp:rvm_block parent="2" /> for grandpa, etc, if it makes sense.

Offline

#22 2015-05-19 19:29:52

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: template inheritance

etc wrote #290931:

I would prefer <txp:rvm_block parent="2" /> for grandpa, etc, if it makes sense.

That was already possible in the plugin, even if I didn’t mention it. :)

Offline

#23 2015-05-19 19:42:12

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: template inheritance

Okay, plugin is uploaded and support topic opened here

Offline

Board footer

Powered by FluxBB