1
Shiva
Adding javascript to a block
  • 2009/9/23 19:37

  • Shiva

  • Quite a regular

  • Posts: 280

  • Since: 2006/7/9 1


Can someone please explain the best way to add javascript to a block?

Thanks in advance :)

2
ghia
Re: Adding javascript to a block
  • 2009/9/23 20:11

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


If you have one block you can put it between the HTML code.
For use in several blocs put the functions in a js file that is added to the header in theme.html

3
Shiva
Re: Adding javascript to a block
  • 2009/9/23 21:08

  • Shiva

  • Quite a regular

  • Posts: 280

  • Since: 2006/7/9 1


Ok, I thought it might have been possible to reference a file in a block_show function.
So do you mean that I just put it in the template file ?

Thank you.

4
Quest
Re: Adding javascript to a block
  • 2009/9/23 22:57

  • Quest

  • Friend of XOOPS

  • Posts: 1034

  • Since: 2005/11/19


It all depends on what you really are trying to do. If you are trying to alter an existing block template then you will need to use template override functionality. Or you could be needing to create your own custom block. In that case create your custom block and add your javascript. All depends on what you are trying to do...

Hope this helps,
Quest

5
ghia
Re: Adding javascript to a block
  • 2009/9/23 23:56

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


If there is only one block that has to include it, then you can use:
<script type="text/javascript" src="abc.js">script>
else put it in the head section of your theme.html

6
optikool
Re: Adding javascript to a block
  • 2009/9/30 1:22

  • optikool

  • Not too shy to talk

  • Posts: 154

  • Since: 2007/3/26


Quote:

Ok, I thought it might have been possible to reference a file in a block_show function.
So do you mean that I just put it in the template file ?


No you wouldn't put your js code in the show_block function. Find the module that the block belongs, then look for it's template file under templates/blocks and add the code there. If you don't want to go through all that then add it to the header part of your theme.html file.

Login

Who's Online

456 user(s) are online (325 user(s) are browsing Support Forums)


Members: 0


Guests: 456


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits