Hallo Lauri,
we face the same problem with our subTemplates.
AFAIK magnolia 4.5 (or 5?) will introduce subTemplates (template variants) also
for the paragraphs. So one solution might be to wait for this release.
Otherwise, it is possible to query the "type" to display within your template
scripts by querying the aggregation state ("state.extension"), eg by writing
something like (freemarker syntax):
[#if state.extension=="xml"]
... display XML Version ...
[#else]
... display normal Version ...
[/#if]
While this is not ideal, it works well. By using #include to include different
template scripts for the different types rather than writing both versions in
the same script you can also keep things pretty readable.
Regards from Vienna,
Richard
-----Ursprüngliche Nachricht-----
Von: [email protected] [mailto:[email protected]]
Im Auftrag von Magnolia Forums (on behalf of Lauri)
Gesendet: Freitag, 04. November 2011 11:58
An: Magnolia User List
Betreff: [magnolia-user] subTemplates and paragraphs. Display paragraph in
.html and .xml
Hello.
Magnolia provides subTemplate feature to display content in different formats.
You define a
[url=http://documentation.magnolia-cms.com/reference/templating.html#Templateconfiguration]sub
template[/url].
A template consist of paragraphs. Something like that
[code]
<cms:contentNodeIterator contentNodeCollectionName="contentCollection">
<cms:includeTemplate />
</cms:contentNodeIterator>[/code]
Where includeTemplate loads a paragraph, defined in a way similar to templates,
with exception of format. Paragraphs unaware of current subTemplate. So if you
want to display content in .xml often you'll find that your xml subtemplate
loads html for paragraphs.
How do I handle it?
I think its possible to write a bigger template which would be aware of content
types to display and would somehow parse paragraph data. Tho it sounds too
complicated. Is there better approach available, i.e. making paragraph
definition aware of subTemplate?
Lauri
--
Context is everything:
http://forum.magnolia-cms.com/forum/thread.html?threadId=7d8903f4-f499-4b18-bba9-935f7b6f962d
----------------------------------------------------------------
For list details, see http://www.magnolia-cms.com/community/mailing-lists.html
Alternatively, use our forums: http://forum.magnolia-cms.com/
To unsubscribe, E-mail to: <[email protected]>
----------------------------------------------------------------
----------------------------------------------------------------
For list details, see http://www.magnolia-cms.com/community/mailing-lists.html
Alternatively, use our forums: http://forum.magnolia-cms.com/
To unsubscribe, E-mail to: <[email protected]>
----------------------------------------------------------------