Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
#1 2009-02-21 17:01:38
- koobs
- Member
- Registered: 2008-11-25
- Posts: 27
Custom Field as a trigger
I’m trying to use a technique mentioned by Tim Van Damme to use a custom field as a trigger to load jquery code into certain pages.
The code in the <head> looks like this
<txp:if_individual_article>
<txp:if_custom_field name="jquery">
<script src="jquery.js" type="text/javascript"></script>
</txp:if_custom_field>
</txp:if_individual_article>
Apparently you can trigger this custom field – and as a result load the code – by specifying a value in the custom field on the write page. It all sounds nice and streamlined but unfortunately it doesn’t seem to work for me.
I am just adding a “1” character to the custom field.
Have I missed something?
thanks for any help
Offline
Re: Custom Field as a trigger
That should work, can’t see anything wrong with that code.
Have you looked at the output source code of your page to check if <script ...></script>
is there when looking at an individual article?
Offline
#3 2009-02-21 17:48:54
- koobs
- Member
- Registered: 2008-11-25
- Posts: 27
Re: Custom Field as a trigger
Nothing is outputted.
I’ll try again and check for typos. Is it correct that adding the “1” to the custom field will trigger it?
Offline
Re: Custom Field as a trigger
Do you see the <script>
tag? If not, then the custom field is not getting triggered. If you see the tag, then jquery is not getting loaded, in which case, check the path to jquery is correct.
Offline
#5 2009-02-21 18:12:57
- redbot
- Plugin Author
- Registered: 2006-02-14
- Posts: 1,410
Re: Custom Field as a trigger
Maybe is a silly suggestion but have you tried with
<txp:if_custom_field name="jquery" val="1">
Offline
#6 2009-02-21 18:22:21
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Custom Field as a trigger
It might be the – relative – path used in here:
<script src="jquery.js" type="text/javascript"></script>
Offline
#7 2009-02-21 18:40:43
- koobs
- Member
- Registered: 2008-11-25
- Posts: 27
Re: Custom Field as a trigger
redbot wrote:
Maybe is a silly suggestion but have you tried with
<txp:if_custom_field name="jquery" val="1">
I’ve tried this to no avail. Does it have to be there?
Els wrote:
It might be the – relative – path used in here:
That path was just simplified for the example.
The <script> tag is not output so the custom field is not getting triggered. hmmmn
Offline
#8 2009-02-21 19:56:49
- redbot
- Plugin Author
- Registered: 2006-02-14
- Posts: 1,410
Re: Custom Field as a trigger
koobs wrote:
I’ve tried this to no avail. Does it have to be there?
No, it doesen’t I think. Was just to make it sure, sorry.
Offline
Re: Custom Field as a trigger
koobs – are you sure your article has a value set in the jquery custom field? And did you run a tag trace?
Offline
#10 2009-02-21 21:08:35
- koobs
- Member
- Registered: 2008-11-25
- Posts: 27
Re: Custom Field as a trigger
erm, I’m rather embarrassed to admit it was my own typo, misspelling the class as fancyzooom! Guess I just looked at it so much I didn’t see it.
Sorry for wasting your time.
Thanks for all your assistance
Offline
Pages: 1