Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2014-09-26 17:30:40

candyman
Member
From: Italy
Registered: 2006-08-08
Posts: 684

Custom header for different pages

Probably there is already a plugin that do what I need but I can’t find it.

I have different pages (map, faq, gallery…) and they need some jquery scripts (gmaps.js and so on…).
In order to make the site lightweight I’ve created different html_head forms (html_head_map, html_head_faq…) which have only the script that the page need.

Is there a method to load the script according to the page?

A thing like: IF the page is “map” THEN load script “gmaps.js”?

Thanks in advance,

Alessandro

Offline

#2 2014-09-26 19:28:22

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,448
Website GitHub

Re: Custom header for different pages

How about:

<txp:output_form form='html_head_<txp:section />' />

Look ma, no plugins!


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#3 2014-09-26 19:52:35

michaelkpate
Moderator
From: Avon Park, FL
Registered: 2004-02-24
Posts: 1,379
Website GitHub Mastodon

Re: Custom header for different pages

A similar trick I like to use in the default page:

<txp:variable name="task" value="frontpage" />

<txp:if_category><txp:variable name="task" value="category" /></txp:if_category>

<txp:if_search><txp:variable name="task" value="search" /></txp:if_search>

<txp:if_author><txp:variable name="task" value="author" /></txp:if_author>

<txp:output_form form="task-<txp:variable name="task" />" />

Offline

#4 2014-09-27 05:44:06

Vienuolis
Member
From: Vilnius, Lithuania
Registered: 2009-06-14
Posts: 310
Website GitHub GitLab Mastodon Twitter

Re: Custom header for different pages

I’ve made the one <txp:output_form form="html_head" /> only, containing a <txp:yield /> tag, though.

Last edited by Vienuolis (2014-09-27 09:54:49)

Offline

Board footer

Powered by FluxBB