Textpattern Forum

You are not logged in. Register | Login | Help

#1 2009-05-15 15:37:33

jsoo
Developer
From: NC, USA
Registered: 2004-11-15
Posts: 1,730
Website

soo_required_files: per-article loading of JavaScript and CSS files

This plugin, in combination with a custom field, allows you to load JavaScript and CSS files in the document <head>, on a per-article basis. Useful if you use a JavaScript/CSS package such as Slimbox and only want to load the relevant files on pages where you actually need them.

Version history

0.2.2, released 2010/07/10

  • Tag contents can now include other Txp tags, allowing e.g. Txp conditional tags for further automation options.

0.2.1, released 2009/10/04

  • Fixed per-page/section loading in sub-directory installations

0.2, released 2009/09/26

  • per-page and/or per-section file loading
  • soo_required_files tag now works either as single or container tag
    • container tag: specify additional files/forms as tag contents
  • use any combination of per-article, per-page, per-section, or tag contents

0.1.1, released 2009/09/18

  • per-article loading of files and forms from a custom field
  • compatible with soo_plugin_pref

Documentation, download, and examples

Last edited by jsoo (2010-07-10 22:40:03)


Txp tags not doing what you expect? Learn to use a tag trace. And the Tag Reference.

Offline

#2 2009-05-15 16:01:39

net-carver
Admin
From: UK
Registered: 2006-03-08
Posts: 1,648

Re: soo_required_files: per-article loading of JavaScript and CSS files

Jeff

thanks for your plugins!


Steve
Textile | My plugins on GitHub | @netcarver

Offline

#3 2009-05-15 16:49:13

jsoo
Developer
From: NC, USA
Registered: 2004-11-15
Posts: 1,730
Website

Re: soo_required_files: per-article loading of JavaScript and CSS files

Thanks Steve — great to see you’re still around the forum. I won’t read too much into this, though ;)


Txp tags not doing what you expect? Learn to use a tag trace. And the Tag Reference.

Offline

#4 2009-05-15 17:57:34

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 4,933
Website

Re: soo_required_files: per-article loading of JavaScript and CSS files

jsoo wrote:

This plugin, in combination with a custom field, allows you to load JavaScript and CSS files in the document <head>, on a per-article basis. Useful if you use a JavaScript/CSS package such as Slimbox and only want to load the relevant files on pages where you actually need them.

Hi J Soo… apologies for not getting this. I’m not sure why this cannot be achieved with <txp:if_article_id ="1,2,5" >... or with <txp:if_custom_field name="javascript" val="js">


Yiannis
——————————
neme.org | neme-imca.org | hblack.net | LABS

Offline

#5 2009-05-15 18:06:33

jsoo
Developer
From: NC, USA
Registered: 2004-11-15
Posts: 1,730
Website

Re: soo_required_files: per-article loading of JavaScript and CSS files

colak wrote:

I’m not sure why this cannot be achieved with <txp:if_article_id ="1,2,5" >...

It can. It just becomes terribly awkward if you’re talking about more than one or two files.

or with <txp:if_custom_field name="javascript" val="js">

Only allows one value in the field.

Last edited by jsoo (2009-05-15 18:07:26)


Txp tags not doing what you expect? Learn to use a tag trace. And the Tag Reference.

Offline

#6 2009-05-15 21:00:11

maniqui
Moderator
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 2,976
Website

Re: soo_required_files: per-article loading of JavaScript and CSS files

It’s nice to have this functionality as a plugin.
Thanks, jsoo.

I also think it could be done (not so) easily using custom fields + built-in tags (as colak posted) mixed with smd_each (yes, it requires a plugin too…, althought smd_each can also be used for other tasks in a site…).


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#7 2009-05-15 21:14:51

jsoo
Developer
From: NC, USA
Registered: 2004-11-15
Posts: 1,730
Website

Re: soo_required_files: per-article loading of JavaScript and CSS files

Good pointer. It’s hard to keep up with all of Bloke’s plugins! It could definitely be done as you say, although I suspect would involve some <txp:php> to get the preg_match() stuff I do to differentiate between files and form names. (I could easily be overlooking something, though.)


Txp tags not doing what you expect? Learn to use a tag trace. And the Tag Reference.

Offline

#8 2009-09-18 14:25:33

jsoo
Developer
From: NC, USA
Registered: 2004-11-15
Posts: 1,730
Website

Re: soo_required_files: per-article loading of JavaScript and CSS files

Version 0.1.1 just released. The only change is compatibility with the soo_plugin_pref plugin preference management system.


Txp tags not doing what you expect? Learn to use a tag trace. And the Tag Reference.

Offline

#9 2009-09-18 18:15:23

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

Re: soo_required_files: per-article loading of JavaScript and CSS files

The plugin is very interesting but, at least, one article must be published to load JavaScript or CSS for a custom page. Is there a way to choose the relevant files without any article?

Offline

#10 2009-09-18 18:55:20

jsoo
Developer
From: NC, USA
Registered: 2004-11-15
Posts: 1,730
Website

Re: soo_required_files: per-article loading of JavaScript and CSS files

candyman wrote:

The plugin is very interesting but, at least, one article must be published to load JavaScript or CSS for a custom page. Is there a way to choose the relevant files without any article?

No, the plugin is intentionally article-based. Can you give me an example of the situation you have in mind?


Txp tags not doing what you expect? Learn to use a tag trace. And the Tag Reference.

Offline

Board footer

Powered by FluxBB