Add area at the bottom of Master page
On a Master page (portal site) we would like to add some JS to the bottom on different pages. It would be really useful to have a field/area/zone that could be used. So that we could put anything we want and this area would put what we wanted just before the closing HTML Body tag.
Hello and thanks for the suggestion.
As the Portal engine is no longer our primary development model, we have no plan to extend this functionality.
Thank you for clarification, variant 2 would be the prefferred solution for us too. We will wait for more votes to see, if there are more customers with the same need.
Ilesh Mistry commented
Sure no worries, I will try to explain here.
The ordering of JS is really important. Basically we all know JS should be placed at the bottom in the Master page, on a Portal Template approach. So we can add this to the bottom just before the closing Body tag. So imagine I did this.
Now for page templates, different pages etc... I want to run some JS code, but this code would run before the code we placed in the Master page. Due to JS requiring things to run in an order, this would mean we would need to try and do something different to make our code run.
This is why I was suggesting to have a field/zone/area (not sure exactly what yet), but this would appear on all Templates/Pages, so then you can say Page 1 will run this Code A, Page 2 can run Code B.
I am hoping this is all making sense.
That is so far for pages, but there is no reason why we can't also have it for Page Templates. So if you add a web part of some sort then it knows to sit at the bottom, under everything else. Just like the Head HTML web part works, you can add this to any zone, but it know exactly where to put the content!
We should look to create two things...
1) Create a Form Controls field, that if added as a field in Document Types, it would allow someone to put some JS to be inserted to the bottom of the page.
2) Create a Footer web part, that would allow people to add JS to the web part to be included at the bottom of the page below the items in the Master Page. This would be exactly the same as the Head HTML web part, but be for the footer instead. This would be my preferred option.
I would be really happy to help progress this with you and really believe we need to find a solution to JS ordering. I think this is pretty urgent and would save us amending the PortalTemplate.aspx file and other Kentico core files for this.
There are many ways how to add JS to master page: either into page layout, page template or via web part. Can you please describe what are you trying to achieve and why one of the supported ways are not suitable for it?
Ilesh Mistry commented
Sorry, no the JS may just be for certain page templates, not for all. However should be available for all templates.