Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-08-08 15:54:58

dreamer
Member
Registered: 2007-06-08
Posts: 242

How to get an article to accept javascript

I needed to put alot of javascript into a new article. It seems that the only way for me to do this is to create the entire article in a form and have that called from the page template. Right?

Because I tried inputting the entire article into the html source option for the WYSIWYG editor but that won’t work. The javascript won’t output. I tried doing the same thing using textile and that won’t work either. Just curious to see if I missed an option?

Offline

#2 2008-08-08 16:46:11

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: How to get an article to accept javascript

Hi dreamer,

you could try a few things:

Option 1: create a form just containing the javascript code and then call the form at the top of the article using <txp:output_form form="my_javascript" />

Option 2: almost the same: create a form just containing the JS code and then include it on the <head></head> using txp:if_article_id. The “problem” you may find in this option is if you need to also include the article (and the js) on an article list context (that is, on a listing of articles, like a section or a category).

Option 3: if the javascript code is all mixed at different parts of the article, you probably can’t go with option 2 (maybe it’s possible with option 1 and then using few forms). In this case, you may want to disable the WYSIWYG for this article (as you have already tried) and then, in front of each line of javascript code, add an empty space, to disable Textile for that line.
There are also some Textile syntax to disable Textile syntax on a block.
Like this notextile. or even better notextile.. (for large chunks of code). The second option (notextile..) has to be escaped the line after your notextile block has ended.

Something like this:

notextile.. <script>
... your code...
...more code...

... even more code after an empty line...

... now, the following line will be a trigger to close the notextile block. I will leave empty, because if I put some text after the "p.", I will end up escaping the "bc.." that is rendering this example, do I explain my self?

</script>

p.

This line you are reading right now starts with a “p.” to escape the above code of block. Hit the “quote” button to see the code.

Hope it helps.

Last edited by maniqui (2008-08-08 16:47:07)


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#3 2008-08-08 22:22:35

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,306

Re: How to get an article to accept javascript

maniqui meant «p. » Note the blank after the dot. (Sorry for intervening, Julian, it’s often the small things that lead to desperation.)


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

Board footer

Powered by FluxBB