Portal Engine Questions on portal engine and web parts.
Version 7.x > Portal Engine > Add HEAD element content: ??? View modes: 
User avatar
Member
Member
positivepurchasing - 1/30/2013 10:44:07 AM
   
Add HEAD element content: ???
Hi,

In edit template there is a tab called 'Header', it says 'Add HEAD element content:' I assumed this meant I could enter something like this
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
and it would be in the <head> of the page, but it is not.

Please can someone help me here as this does not make sense and help me reference resources such as jQuery.

Cheers
Paul.

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 1/31/2013 1:45:44 AM
   
RE:Add HEAD element content: ???
Assuming you want jquery on all your pages, you can simply place it in your master page. Your link would look something like this:
<script src="/CMSPages/GetResource.ashx?scriptfile=%7e%2fCMSScripts%2fjquery%2fjquery-core.js" type="text/javascript"></script>

User avatar
Member
Member
positivepurchasing - 1/31/2013 3:06:21 AM
   
RE:Add HEAD element content: ???
Thanks for your reply, but I'm no clearer on what to do.

I'm using portal engines pages. Where do I put the script tag? I'd like it to be in the head section of my pages.

Also how is anyone supposed to know that awful url?

User avatar
Kentico Support
Kentico Support
kentico_janh - 1/31/2013 10:43:49 AM
   
RE:Add HEAD element content: ???
Hello,

You can find the mentioned location when you select your root document (master page) in your content tree and switch to the Master page tab. On this tab you are able to place tags within the HEAD part of your page. You can achieve the same result by placing the Head HTML code web part on the master page (or on any other document which you want to use the jQuery library on) and filling that "awful" path. This path looks awful only, because slashes are encoded. You can use following code as well:

<script src="/CMSPages/GetResource.ashx?scriptfile=/CMSScripts/jquery/jquery-core.js" type="text/javascript"></script>


Best regards,
Jan Hermann

User avatar
Member
Member
positivepurchasing - 2/1/2013 3:54:53 AM
   
RE:Add HEAD element content: ???
Hi Jan,

Yeah I understand the encoding, I just do not understand Kentico.

'/CMSPages/GetResource.ashx?scriptfile= ... '

I've AGAIN wasted hours on something extremely simple, there is nothing intuitive about the above line.

Does it work for css files?

If only you were in my shoes then you would understand that it is awful trying to battle Kentico to do even the most simplest of things.


Cheers
Paul.

User avatar
Kentico Support
Kentico Support
kentico_janh - 2/1/2013 8:42:19 AM
   
RE:Add HEAD element content: ???
Hello,

It is not mandatory to use mentioned code, you can use your one as well, however why would you link the jQuery library from external source when one is already a part of your Kentico solution. What I am trying to tell is that are many many ways how to generally add a code (not even link to a javascript file) between head tags of your outputed markup:

- <root document> -> Master page tab
- <root document> -> Design tab -> Head HTML code web part
- master page template -> Header section
- <any document> -> Design tab -> Head HTML code web part
- CMSPages/portaltemplate.aspx

And specially for javascript we have the Javascript web part.

And yes, this approach works for css styles as well:

<link href="/CMSPages/GetResource.ashx?stylesheetname=StylesheetName" type="text/css" rel="stylesheet"/>

or

<link href="/CMSPages/GetResource.ashx?stylesheetfile=/pathToAStylesheet/style.css" type="text/css" rel="stylesheet"/>

Best regards,
Jan Hermann

User avatar
Kentico Support
Kentico Support
kentico_janh - 1/31/2013 10:44:45 AM
   
RE:Add HEAD element content: ???
Hello,

Alternatively, you can follow instruction in the article below:

How to register and use the native Kentico jQuery library

Best regards,
Jan Hermann