UseBB Community

The official board for UseBB help and discussion

UseBB Community » Help & Support » Javascript enable in tpl

Javascript enable in tpl

Moderators: Gaia.

Page: 1

Author Post
Member
Registered: Jul 2005
Posts: 232
Location: Stockholm
I would like to be able to use javascript code in the tpl's as it doesen't seem to work now it just show up an error.at the moment. The reson is that i want to use a pop up link but i can't find any other way than using javascript for this.

Regards
Developer
Registered: Apr 2004
Posts: 2216
Location: Belgium
Why doesn't it work? Have you tried 0.7?
_______________
--Dietrich (developer)
UseBB roadmap, dev mailing list & weblog
Member
Registered: Jul 2005
Posts: 232
Location: Stockholm
i haven't tried 0.7 (you mean the CVS version right?) but in 0.6a it shows up this error


Parse error: parse error, unexpected T_STRING in /hsphere/local/home/jiraiya/usebb.jiraiya.se/start/templates/J-Designs/global.tpl.php on line 124
Developer
Registered: Apr 2004
Posts: 2216
Location: Belgium
Must be because you are breaking the string encapsed with single quotes... Normally JavaScript works, but some small fixed were put in CVS so it now even works very well in a post if you are able to post HTML.
_______________
--Dietrich (developer)
UseBB roadmap, dev mailing list & weblog
Member
Registered: Jul 2005
Posts: 232
Location: Stockholm
but is it smart to use CVS for your community? Doesen't it get hard to upgrade and so on
Developer
Registered: Apr 2004
Posts: 2216
Location: Belgium
For the moment I don't think there's a problem, but of course 0.6 is recommended, just in this case to test if stuff works. But I'm sure you just broke the string the template is in. You'll need to escape the single quotes in your Javascript.
_______________
--Dietrich (developer)
UseBB roadmap, dev mailing list & weblog
Member
Registered: Jul 2005
Posts: 232
Location: Stockholm
but i'll test the CVS.. but isn't it possible to add javascript code to a singe .js file and have an include javascript.js or something
Developer
Registered: Apr 2004
Posts: 2216
Location: Belgium
Sure it is, but still it should work in the templates themselves too.
_______________
--Dietrich (developer)
UseBB roadmap, dev mailing list & weblog
Member
Registered: Jul 2005
Posts: 232
Location: Stockholm
ok i use a code like this

<A HREF="http://site.se/popup/" TARGET="popup" ONCLICK="window.open('http://site.se/popup/', 
'popup', 'width=804,height=384'); return false">Enter popup</A>


i haven't tried 0.7 yet though..
Developer
Registered: Apr 2004
Posts: 2216
Location: Belgium
Well you're using single quotes that need to be escaped...
_______________
--Dietrich (developer)
UseBB roadmap, dev mailing list & weblog
Member
Registered: Jul 2005
Posts: 232
Location: Stockholm
what do you mean with single quotes?
Developer
Registered: Apr 2004
Posts: 2216
Location: Belgium
<A HREF="http://site.se/popup/" TARGET="popup" ONCLICK="window.open(\'http://site.se/popup/\', 
\'popup\', \'width=804,height=384\'); return false">Enter popup</A>

This is what you need. :)
_______________
--Dietrich (developer)
UseBB roadmap, dev mailing list & weblog
Member
Registered: Jul 2005
Posts: 232
Location: Stockholm
oh thanks man. I undetstand about the single quotes now and it helped me with some other stuff as well

Page: 1

UseBB Community » Help & Support » Javascript enable in tpl

UseBB Community is powered by UseBB 1 Forum Software