Setting mime type on Hippo document?

42 views
Skip to first unread message

Elizabeth Reid

unread,
Aug 31, 2015, 5:25:31 PM8/31/15
to Hippo Community
As far as I can tell, the mime type on documents generated by Hippo is set to text/html by default. Which makes sense; most documents managed through Hippo are going to be web pages. 

However, we have a special case where we need to dynamically generate a CSS file based on settings in a Doc Type. We have everything working to render the CSS file contents (hst:template entry hooked to a template, hst:pages entry hooked to the hst:template, hst:sitemap entry hooked to the hst:page). The resulting CSS file contents load at the requested URL, but the content type is served with the text/html content type.

Is there a way (through Hippo) to change the mime type served for this page to text/css so that it will be treated correctly as a CSS file?

Thanks
-Elizabeth

William Borg Barthet

unread,
Aug 31, 2015, 5:51:50 PM8/31/15
to hippo-c...@googlegroups.com
Hi Elizabeth,

would something like calling response.setHeader() in the HST component work?

HTH

William

--
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 - 745 Atlantic Avenue, Boston, MA 02111

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

Elizabeth Reid

unread,
Sep 1, 2015, 4:12:22 PM9/1/15
to Hippo Community
On Monday, August 31, 2015 at 5:51:50 PM UTC-4, w.borgbarthet wrote:
Hi Elizabeth,

would something like calling response.setHeader() in the HST component work?

HTH

William

We were trying to avoid adding backend code just for this, if possible. I did notice that there's a mix:mimeType under the Mixin Types, which certainly sounds like it should be related to what we're trying to do, but I haven't found any documentation on it or how one might use it. 

Elizabeth Reid

unread,
Sep 3, 2015, 3:08:35 PM9/3/15
to Hippo Community

William,

Is there any way to call response.setHeader() from within a Freemarker template? If that was possible, that might solve the problem, but I'm not sure the Freemarker templates have that kind of logic available in them.



On Monday, August 31, 2015 at 5:51:50 PM UTC-4, w.borgbarthet wrote:

Elizabeth Reid

unread,
Sep 3, 2015, 3:34:43 PM9/3/15
to Hippo Community
After a lot of searching on Google, I finally found a solution to this. You can specify a custom mime type in the Freemarker Template by setting the attributes parameter on the <#ftl> tag, as so:

<#ftl encoding="UTF-8" attributes={"content_type": "text/css"}>

It does appear that this has to be first line in the template or there's a parsing error. But once it's in there, requesting the CSS file correctly sends back a type of text/css in the headers.

Steven Fockema Andreae

unread,
Sep 3, 2015, 3:52:56 PM9/3/15
to hippo-c...@googlegroups.com
Great Elizabeth,

Im not a tech guy, but think your research and input is great and by the sound of it very useful 
--
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.


--
With kind regards | met vriendelijke groet |  Mit freundlichen Grüßen  

Steven Fockema Andreae  | +31 6 1959 6953 |
Partner Management Director


Amsterdam - Oosteinde 11, 1017 WT Amsterdam

_______________________________________________________________
This e-mail may be privileged and/or confidential, and the sender does not 
waive any related rights and obligations. Any distribution, use or copying 
of this e-mail or the information it contains by other than an intended 
recipient is unauthorized. If you received this e-mail in error, please 
advise me (by return e-mail or otherwise) immediately.

Reply all
Reply to author
Forward
0 new messages