MagnoliaTemplateUtilities renderParagraph in Versions prior to 4.0

View: New views
2 Messages — Rating Filter:   Alert me  

MagnoliaTemplateUtilities renderParagraph in Versions prior to 4.0

by Sebastian Schuon :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hi all,
I am looking to render a paragraph by specifying its handle (here the
variable src). I believe the following should do exactly this in
magnolia 4.0 and higher:

    HierarchyManager mgr =
MgnlContext.getHierarchyManager(ContentRepository.WEBSITE);
    Content uriContent = mgr.getContent(src);
    MagnoliaTemplatingUtilities mgnl = (MagnoliaTemplatingUtilities)
pageContext.getAttribute("mgnl", PageContext.REQUEST_SCOPE);
    mgnl.renderParagraph(uriContent);

Unfortunately we are running 3.6.5, has anyone an idea how I would do
this in 3.6.5?
Best,
Sebastian

----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <user-list-unsubscribe@...>
----------------------------------------------------------------


Re: MagnoliaTemplateUtilities renderParagraph in Versions prior to 4.0

by Åke Argéus :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


I don't have the 3.6.5 code checked out so I might be completely off  
here, but maybe you can try doing what the templatingustils do?

final Content backup = MgnlContext.getAggregationState
().getCurrentContent();
         MgnlContext.getAggregationState().setCurrentContent
(paragraphNode);
         Paragraph paragraph = ParagraphManager.getInstance
().getParagraphDefinition(paragraphName);
         ParagraphRenderingFacade.getInstance().render(paragraphNode,  
paragraph, out);
         MgnlContext.getAggregationState().setCurrentContent(backup);

Though I would recommend setting the backup-node back in a finally-
clause since any exceptions or errors during rendering messes up the  
whole page in my experience.


3 nov 2009 kl. 10.39 skrev Sebastian Schuon:

>
> Hi all,
> I am looking to render a paragraph by specifying its handle (here the
> variable src). I believe the following should do exactly this in
> magnolia 4.0 and higher:
>
>   HierarchyManager mgr =
> MgnlContext.getHierarchyManager(ContentRepository.WEBSITE);
>   Content uriContent = mgr.getContent(src);
>   MagnoliaTemplatingUtilities mgnl = (MagnoliaTemplatingUtilities)
> pageContext.getAttribute("mgnl", PageContext.REQUEST_SCOPE);
>   mgnl.renderParagraph(uriContent);
>
> Unfortunately we are running 3.6.5, has anyone an idea how I would do
> this in 3.6.5?
> Best,
> Sebastian
>
> ----------------------------------------------------------------
> For list details see
> http://www.magnolia-cms.com/home/community/mailing-lists.html
> To unsubscribe, E-mail to: <user-list-unsubscribe@...>
> ----------------------------------------------------------------
>


----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <user-list-unsubscribe@...>
----------------------------------------------------------------