Maybe this is not the right question - so i will likely end up posting this a couple times here.
=================

What do i do to have a module put a piece HTML code ONCE into my page ?

I was trying to use hook_nodeapi which sort of works.. except that my page has 3 nodes on it.. therefore it was doing this 3 times... which in FF it didn't seem to be an issue (not sure why not.. likely it was doing it but other 2 copies were buried).. but they show up in IE.

the html i am adding doesn't really matter where it goes - since it is a DIV with absolute postioning... but would be nice if i could get it to go in the html body.

I read that i could use hook_menu and that sort of works in FF but, again, not very well in IE... and makes ugly HTML since it throws my html before the html tag.

but perhaps i am not using hook_menu correctly???

Comments

frankr-1’s picture

Never tried this but what about hook_footer?
___________________________________
http://aqon.com

liquidcms’s picture

i took a look at hook_footer and it sounds like what i am looking for; but seems to do the same thing as hook_menu

any chance you have an example?

this is what i did:

function my_ajax_footer ($main=0) {
  
      $block_id = "'ajax'";
      $delay_time = 3000;
      $top = "122px"; $left = "380px";
      
     
      $path = drupal_get_path('module', 'my_ajax');
      drupal_add_js($path . '/my_ajax.js');
      theme_add_style($path . '/my_ajax.css');
      echo " some html here ";    

sorry.. i would have posted real html that goes in here.. but this forum sucks... and wont let me...

basically it is div and img tags

heine’s picture

Beware with echo & print in hook_ implementations! According to the API docs for hook_footer you need to return the HTML that has to be printed above the closing body tag (the contents will end up in the phptemplate variable $closure for example).

As to your hook_nodeapi experiments: it's certainly not the way to do it, go with hook_footer, but PHP has some sort of persistent local variables that you may well know from other languages. These are called static variables. You can use these for example to count how often a function is called.

The last line of your code should read:

  return "some html here";

Good luck!

Heine

PS The XSS filter is very stringent, that's why some tags lead to the 'suspicious content' warning.

--
Tips for posting to the forums.
When your problem is solved, please post a follow-up to the thread you started.

liquidcms’s picture

ahhh.. i seeeee... cool.. that makes more sense...

i'll give it shot.

liquidcms’s picture

very cool.... that was it

i guess in the API it does state:

Return value

The HTML to be inserted. 

doohhhh!!.

check it out if ya like... http://www.allanalog.com/d0214/

my little module does the AJAX "showcase" that scrolls through nodes in a specific category and dumps them into my header...

the hook_footer bit adds the little control panel thing just above it.

cheers,

seaneffel’s picture

Write the HTML code into your phptemplate files. In the theme directories that I am familiar with there are files called like page.php.tmp and node.php.tmp.etc or some sort that control the layout of your site as code is pulled from your database. You can hardcode the HTML in there or make up a server side include that directs to a file with the HTML in it. Be better to do an SSI because then you don't have to mess around with your template files each time you want to change that. I can give you more info if you email me, if you need it.

Sean
Cambridge Community Television
http://www.cctvcambridge.org

liquidcms’s picture

Hi Sean,

i suspect i was not clear enough in what i am trying to do.

I am designing a module. the module needs to add some floating (i.e. abs position) img's to my page...

This is not static.. they are added to each page if the module is enabled.. and more specifically they are distributed with the module... therefore can't be added to .tpl theme files

but thanks for the reply..