<hst:headContribution category="css"> does not work at a certain page.

185 views
Skip to first unread message

arsdeep.singh

unread,
Oct 30, 2014, 2:29:30 PM10/30/14
to hippo-c...@googlegroups.com

I am using hippo cms 7.9.3

 

I want to add a css file in my head from a content jsp.

I tried

<hst:headContribution category="css">

    <link href="<hst:link path="css/cssfile.css" />" type="text/css" rel="stylesheet" />

</hst:headContribution>

This did worked in test.jsp, The css file is added in the head at a postion. 

In webpage.jsp it did not worked, see code below:

<%@ include file="/WEB-INF/jspf/htmlTags.jspf" %>

<html lang="en">

    <head>

        <meta charset="utf-8">

 

        <hst:link var="favicon" path="/images/favicon.ico" />

        <link rel="icon" href="${favicon}">

 

    </head>

    <body>

   

    <hst:headContribution category="css">

    <link href="<hst:link path="css/cssfile.css" />" type="text/css" rel="stylesheet" />

    </hst:headContribution>

 

            <div id="main">

                <hst:include ref="header" />

                <hst:include ref="main" />

                <hst:headContributions categoryIncludes="scripts" xhtml="true" />

                <hst:include ref="footer" />

            </div>

    </body>

</html>


What I want to achieve

I want the [green] code in my my webpage.jsp and that it will work.

 

Business logic.

I want to add a css file only for one page, so I use <hst:headContribution category="css">. But this css file needs to be below a another certain css file else it will overrule it the css.

 

Any ideas/suggestion how the [green] code will work in my webpage.jsp?

 

Thanks in advance.

 

Regards,

Arsdeep

 

Woonsan Ko

unread,
Oct 30, 2014, 2:49:11 PM10/30/14
to hippo-c...@googlegroups.com
Hi Arsdeep,

I think it's because there's no <hst:headContributions ... /> tag to
flush head contribution items of 'css' category.
So, for example, it would work if you did like the following:

<html lang="en">

<hst:headContribution category="css">
<link href="<hst:link path="css/cssfile.css" />" type="text/css"
rel="stylesheet" />
</hst:headContribution>

<head>
<meta charset="utf-8">
<hst:link var="favicon" path="/images/favicon.ico" />
<link rel="icon" href="${favicon}">
<hst:headContributions categoryIncludes="css" xhtml="true" />
</head>
...

Your webpage.jsp seems to be the root page template which is responsible
for flushing all the head contribution elements by using
<hst:headContributions /> tags.
If so, actually you don't need to use <hst:headContribution /> tag again
in the root template page. Instead just use it like this. :)

<html lang="en">

<head>
<meta charset="utf-8">
<hst:link var="favicon" path="/images/favicon.ico" />
<link rel="icon" href="${favicon}">
<link href="<hst:link path="css/cssfile.css" />" type="text/css"
rel="stylesheet" />
</head>

Regards,

Woonsan

On 10/30/14 2:29 PM, arsdeep.singh wrote:
> I am using hippo cms 7.9.3
>
>
>
> I want to add a css file in my head from a content jsp.
>
> I tried
>
> <hst:headContributioncategory=*"css"*>**
>
> * *<linkhref=*"<hst:link path="*css/cssfile.css" />*" type="text/css"
> rel="stylesheet" />*
>
> </hst:headContribution>
>
> This did worked in test.jsp, The css file is added in the head at a
> postion.
>
> In webpage.jsp it did not worked, see code below:
>
> <%@ include file="/WEB-INF/jspf/htmlTags.jspf" %>**
>
> <htmllang=*"en"*>**
>
> * *<head>**
>
> * *<metacharset=*"utf-8"*>**
>
> * *
>
> * *<hst:linkvar=*"favicon"*path=*"/images/favicon.ico"*/>**
>
> * *<linkrel=*"icon"*href=*"${favicon}"*>**
>
> * *
>
> * *</head>**
>
> * *<body>**
>
> * *
>
> * *<hst:headContributioncategory=*"css"*>**
>
> * *<linkhref=*"<hst:link path="*css/cssfile.css" />*" type="text/css"
> rel="stylesheet" />*
>
> * *</hst:headContribution>**
>
> * *
>
> * *<divid=*"main"*>**
>
> * *<hst:includeref=*"header"*/>**
>
> * *<hst:includeref=*"main"*/>**
>
> *
> *<hst:headContributionscategoryIncludes=*"scripts"*xhtml=*"true"*/>**
>
> * *<hst:includeref=*"footer"*/>**
>
> * *</div>
>
> * *</body>**
>
> </html>
>
>
> *What I want to achieve*
>
> I want the [green] code in my my webpage.jsp and that it will work.
>
>
>
> Business logic.
>
> I want to add a css file only for one page, so I use
> <hst:headContribution category="css">. But this css file needs to be
> below a another certain css file else it will overrule it the css.
>
>
>
> Any ideas/suggestion how the [green] code will work in my webpage.jsp?
>
>
>
> Thanks in advance.
>
>
>
> Regards,
>
> Arsdeep
>
>
>
> --
> 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
> <mailto: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.


--
w....@onehippo.com www.onehippo.com
Boston - 101 Main Street, Cambridge, MA 02142
Amsterdam - Oosteinde 11, 1017 WT Amsterdam
US +1 877 414 4776 (toll free)
Europe +31(0)20 522 4466

arsdeep.singh

unread,
Oct 31, 2014, 4:33:14 AM10/31/14
to hippo-c...@googlegroups.com

Hi Woonsan,

 

Thanks for the very quick response. 

 

Normally I would add the css code below, but now I want to have my css file at the very top level, the first css file of the generated html.

The cssfile.css is actually the root css and need to be  above all other css files.

Code <link href="<hst:link path="css/cssfile.css" />" type="text/css"  rel="stylesheet" /> 

 

It did not the trick for me what I wanted to achieve.

 

Actions I have executed in webpage.jsp

I put the code before the <head>:

 

<html lang="en">

<hst:headContribution category="css"> 
  <link href="<hst:link path="css/cssfile.css" />" type="text/css" rel="stylesheet" /> 
 </hst:headContribution> 

 

<head>………………………………………

 

Actions i executed in test.jsp (other jsp) uses template webpage.jsp

<hst:headContribution category="css"> 
  <link href="<hst:link path="css/test.css" />" type="text/css" rel="stylesheet" /> 
 </hst:headContribution> 

 

Generated html (problem)

<link rel="stylesheet" type="text/css" href="/css/test.css"/> (this file was added in test.jsp)

<link rel="stylesheet" type="text/css" href="/css/cssfile.css"/>  (this file was added in webpage.jsp) This one need to be first.

 

Any ideas suggestions how I can achieve my goal?


Regards,

Arsdeep 




Op donderdag 30 oktober 2014 19:49:11 UTC+1 schreef w.ko:

Tobias Jeger

unread,
Oct 31, 2014, 5:26:04 AM10/31/14
to hippo-c...@googlegroups.com
Hi Arsdeep,

what about the following:

webpage.jsp:

<html>
  <head>
    <link rel="stylesheet" type="text/css" href="/css/cssfile.css"/>
   
<hst:headContributions categoryIncludes="css" xhtml="true" />
    [... more ...]
  </head>
  <body>
    [...]
  </body>
</html>

====

test,jsp:

[...]
<hst:headContribution category="css"> 
  <link href="<hst:link path="css/test.css" />" type="text/css" rel="stylesheet" /> 
</hst:headContribution>
[...]

====

That will put the inclusion of your cssfile.css first, and all other contributions afterwards.

cheers

Tobi



To unsubscribe from this group and stop receiving emails from it, send an email to hippo-communi...@googlegroups.com.



--
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

arsdeep.singh

unread,
Oct 31, 2014, 5:41:10 AM10/31/14
to hippo-c...@googlegroups.com
Hi Tobi,

Thanks a lot, this did the trick for me.

Cheers,
Arsdeep

Op vrijdag 31 oktober 2014 10:26:04 UTC+1 schreef t.jeger:
> Visit this group at http://groups.google.com/group/hippo-community.
> For more options, visit https://groups.google.com/d/optout.


--
w....@onehippo.com     www.onehippo.com
Boston - 101 Main Street, Cambridge, MA 02142
Amsterdam - Oosteinde 11, 1017 WT Amsterdam
US +1 877 414 4776 (toll free)
Europe +31(0)20 522 4466

--
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.

Tobias Jeger

unread,
Oct 31, 2014, 5:48:57 AM10/31/14
to hippo-c...@googlegroups.com
You're welcome.

One more thing I'd like to add: I often see that people try to use head contribution category names
to indicate the type of content for the category, like "css" in your case. However, most cases of head-contributions
I see in real projects worry about *where* they get included, not what it is. So your head contribution name may turn
out to have greater value in the future if you change it to "head-tag" or "head-second" (since you want cssfile.css to come first)
or similar. I often see as few as two categories needed: one to include stuff in the <head> element, and one to append JS code
to the end of the <body> tag.

cheers

Tobi

arsdeep.singh

unread,
Oct 31, 2014, 6:17:54 AM10/31/14
to hippo-c...@googlegroups.com
Interesting it does make sense. I refactored it. Thanks

Op vrijdag 31 oktober 2014 10:48:57 UTC+1 schreef t.jeger:
Reply all
Reply to author
Forward
0 new messages