Example using the EssentialsDocumentComponent?

70 views
Skip to first unread message

Steve McCoole

unread,
Nov 21, 2014, 2:08:28 AM11/21/14
to hippo-c...@googlegroups.com
Hi all,

Just wondering if there is an example of using the document component anywhere?  I have an instance of it defined for my page and I am passing the document parameter to it with a path relative to the site content root, but I can't seem to access it in the template.  I have it set in the console with the component class, parameter names and parameter values.

I wasn't absolutely sure but I did do an <@hst.include ref="component name"/> in the template.

I thought then that I should be able to access the attributes through ${document.attribute} but I get an exception saying document isn't defined.

Am I setting this up incorrectly or trying to use it in an unintended way?

Thanks,
Steve


Tobias Jeger

unread,
Nov 21, 2014, 2:45:36 AM11/21/14
to hippo-c...@googlegroups.com
Hi Steve,

your usage of the EssentialsDocumentComponent seems correct. (I trust you have found [1]).
Your hst:include must be working correctly, you wouldn't get the exception otherwise.
Maybe you can debug

org.onehippo.cms7.essentials.components.CommonComponent#setContentBeanForPath()

to see if the reading of documentPath from the component configuration goes wrong, or the loading
of the document bean?

cheers

Tobi



--
Hippo Community Group: The place for all discussions and announcements about Hippo CMS (and HST, repository etc. etc.)
 
To post to this group, send email to hippo-c...@googlegroups.com
RSS: https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
---
You received this message because you are subscribed to the Google Groups "Hippo Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hippo-communi...@googlegroups.com.
Visit this group at http://groups.google.com/group/hippo-community.
For more options, visit https://groups.google.com/d/optout.



--
Amsterdam - Oosteinde 11, 1017 WT Amsterdam
Boston - 101 Main Street, Cambridge, MA 02142

US +1 877 414 4776 (toll free)
Europe +31(0)20 522 4466
www.onehippo.com

Steve McCoole

unread,
Nov 21, 2014, 2:55:29 AM11/21/14
to hippo-c...@googlegroups.com
Thanks Tobi,  I got it to work.  I was trying to use it without a template attribute set when I attached the component to the page, so I moved it up a level and rather than trying to include it in  the template I made that higher level an instance of the document component.  Previously that level only pointed to a template and did not have a class.  I was tweaking several things at once including the paths so I am not 100% sure that defining a template for the document component was the entire fix.  Should I be able to use the document component without a template attribute directly on it?

Tobias Jeger

unread,
Nov 21, 2014, 3:09:38 AM11/21/14
to hippo-c...@googlegroups.com
Hi Steve,

thing is, the EssentialsDocumentComponent makes the bean representing your document available on *that component's request*. If you wanted to render attributes of your document in a template which is not linked to your component by means of the HST configuration, your document bean would not be available. So, the normal case is that the template hierarchy mirrors the component hierarchy.

If you have a valid use case, you could work around this by extending the EssentialsDocumentComponent to copy the request's REQUEST_ATTR_DOCUMENT attribute into your HstRequestContext in order to make it available to all templates globally, but I must say I haven't come across a situation where such a solution would have been appropriate. And you'd need to be careful to avoid attribute name collisions...

cheers

Tobi

Reply all
Reply to author
Forward
0 new messages