Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
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
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
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
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
Re: template inheritance
It’s not better or worse. Just different.
Offline
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
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
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
Offline
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
Offline