Jahia Template Forum > A simple render...

0 (0 Good)
0 (0 Bad)

A simple render filter to add html5 <meta> tag from any Jahia 6.6.x.x module.

by  fabu »  2013/09/19 22:56

Hello, 

Just in case,

I couldn't find how to insert <meta> tag into html template head from a Jahia component.

e.g. Twitter cards or Facebook open graph implementation from an article.

So I hope it will also be useful for someone else.

https://gist.github.com/f4bien/6630632

Regards,

  • A simple render filter to add html5 <meta> tag from any Jahia 6.6.x.x module.
    2013/09/19 22:56

    fabu <p> Hello,&nbsp;</p> <p> Just in case,</p> <p> I couldn&#39;t find how to insert &lt;meta&gt; tag into html template head from a Jahia component.</p> <p> e.g. Twitter cards or Facebook open graph implementation from an article.</p> <p> So I hope it will also be useful for someone else.</p> <p> <a href="https://gist.github.com/f4bien/6630632" title="gist to add &lt;meta&gt; tag from a Jahia component">https://gist.github.com/f4bien/6630632</a></p> <p> Regards,</p>

  • Number of messages  28
    Registration date Sep 19, 2013
    0 (0 Good)
    0 (0 Bad)

    Re : A simple render filter to add html5 <meta> tag from any Jahia 6.6.x.x module.

    by  faissah »  2013/10/04 21:35

    Thanks a lot for your contribution fabu!

    If you want, please feel free to add it on the new Jahia Forge.

    Thanks again,

    Fabrice

    Fabrice  (faissah)

    Number of messages  264
    Registration date
    0 (0 Good)
    0 (0 Bad)

    Re : A simple render filter to add html5 <meta> tag from any Jahia 6.6.x.x module.

    by  theklem »  2013/10/04 23:55

    Hi, what kind of meta did you want to add ?

    Because usually you don't have to create a component nor a filter for that, there are different methods to achieve that goal, it mostly depends on the use case.

    In my opinion

    - If it's the same exact meta you want in all your pages, you may just have added this declaration into the base template (the jsp file that is used as the basis of all templates).

    The file is located  in /modules/mytemplatesetName/jnt_template/html/template.mytemplatesetName.jsp)

    ex: <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

     

    - If the value to insert in the meta is a variable that must be retrieved automatically but may be different from page to page , you may have done the same but use some scripting to retrieve/calculate the desired value.

    ex: <meta name="whatever" content="whatever script you want to execute" />  

     

    - And finally if this meta tag has to be entered manually page by page by your editors, you may have defined a new property for the page object  for instance (extend it) and call this property directly in the base template.

    ex: <meta name="keywords" content="${fn:escapeXml(keywords)}" /> (keywords is a field that can be filled for each page by the editors in the editing form, tab "metadatas".

     

    Obviously, using a filter should works also.

  • Re : A simple render filter to add html5 <meta> tag from any Jahia 6.6.x.x module.
    2013/10/04 23:58

    theklem <p> Hi, what kind of meta did you want to add ?</p> <p> Because usually you don&#39;t have to create a component nor a filter for that, there are different methods to achieve that goal, it mostly depends on the use case.</p> <p> In my opinion</p> <p> - If it&#39;s the same exact meta you want in all your pages, you may just have added this declaration into the base template (the jsp file that is used as the basis of all templates).</p> <p> The file is located &nbsp;in /modules/<em>mytemplatesetName</em>/jnt_template/html/template.<em>mytemplatesetName</em>.jsp)</p> <p> ex:&nbsp;&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;</p> <p> &nbsp;</p> <p> - If the value to insert in the meta is a variable that must be retrieved automatically but may be different from page to page , you may have done the same but use some scripting to retrieve/calculate the desired value.</p> <p> ex: &lt;meta name=&quot;whatever&quot; content=&quot;whatever script you want to execute&quot; /&gt; &nbsp;</p> <p> &nbsp;</p> <p> - And finally if this meta tag has to be entered manually page by page by your editors, you may have defined a new property for the page object &nbsp;for instance (extend it) and call this property directly in the base template.</p> <p> ex: &lt;meta name=&quot;keywords&quot; content=&quot;${fn:escapeXml(keywords)}&quot; /&gt; (keywords is a field that can be filled for each page by the editors in the editing form, tab &quot;metadatas&quot;.</p> <p> &nbsp;</p> <p> Obviously, using a filter should works also.</p>

  • Number of messages  85
    Registration date Oct 4, 2013
    0 (0 Good)
    0 (0 Bad)

    Re : A simple render filter to add html5 <meta> tag from any Jahia 6.6.x.x module.

    by  linubik »  2016/05/11 06:48

    Hi,

    The link seems out of date, but I have the same need (to set og meta tags in a Jahia page : useful for Facebook)

    Does it work with Jahia 7.x ?

    Thanks

    linubik
    Number of messages  1
    Not registered
    0 (0 Good)
    0 (0 Bad)

    Re : Re : A simple render filter to add html5 <meta> tag from any Jahia 6.6.x.x module.

    by  Frank »  2016/05/11 09:13

    The github is still available and there is no reason why this should not work with Jahia DX 7. The filters mechanism has not changed

    Frank
    Number of messages  1
    Not registered
    Contact
    Share
    Feedback

    Get in touch

    Whether you are a current user or if you are just evaluating Jahia, we are here to help.

    Contact us

    Share this page