[Help] How do I insert Javascript into a template

piam

Joined: 2010-10-14
Posts: 5
Posted: Fri, 2010-10-22 23:28

Hi,

I'm just starting out trying to write a module, and I went through the module development tutorial, which btw was a life saver.
Now I'm stuck trying to do the most basic thing.
I can't figure out how to have my module insert some html or javascript into the header.

I'm looking at the search module for inspiration, but I can't figure out how it works.
There seems to be some magic going on with blocks and preloads.inc, can anyone explain how preload works?
Or maybe show me a simple example of how to add a block?

Any advice would be appreciated.

Cheers,
piam

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Sat, 2010-10-23 03:16

take a look at a module which does this like the slideshow module.

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
piam

Joined: 2010-10-14
Posts: 5
Posted: Mon, 2010-11-01 17:30

Thanks Suprsidr,

I'm checking that out now.
A quick question, I notice that some modules are compiled, is that a necessity?
I couldn't find any information on that, I'm not sure what is being compiled or why, did I miss something in the tutorial?

Cheers,
piam

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Mon, 2010-11-01 21:31

if you use $template->javascript('lib/my.js'); then it gets compiled, but you can add it directly to your templates as well.

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
piam

Joined: 2010-10-14
Posts: 5
Posted: Mon, 2010-11-08 23:50

Can I ask what IDE you guys use?
Right now I use notepad++, but I would like to use something with auto complete and other intellisense features.

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Tue, 2010-11-09 00:21

try netbeans

I personally use Aptana Studio, but mine is an older version before they screwed-up the php support.

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
piam

Joined: 2010-10-14
Posts: 5
Posted: Tue, 2010-11-09 00:45

I *was* using Aptana before, and I got tired of pulling my hair out, and went to notepad++.
I'll try netbeans, thanks.

So I'm thinking that reverse engineering from slideshow is a bit much.

All I want to do is shove some javascript into a block thats on every page.
I'm a little surprised by how non-trivial that is.

I's there a simple way of doing this that I'm missing?

--piam

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Tue, 2010-11-09 12:00
 
piam

Joined: 2010-10-14
Posts: 5
Posted: Wed, 2010-11-10 06:06

I'm not at all clear on how to get a block template to load.
I'm trying to do that using this info: http://codex.gallery2.org/Gallery2:How_To_Create_Blocks

So in this case, they have some stuff in Example.tpl and blocks.inc shoves Example it into an $blocks array.
After that, when/why does it ever come up?

As it stands just following the instructions on that page and adding a block template to my basic tutorial page does nothing.
should I be seeing something, or am I missing a step?

Cheers,
piam

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Wed, 2010-11-10 12:13

I cannot give you more detailed tutorial than the one you reference.
But don't forget to add the block to your display in your theme settings.

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2