hello, i have a question.
How can i for example put a google add above my logo-banner on my drupal site. I lowered the banner in Style.css but what can i do now to put my google things above it without using blocks or menu's.
Just in template ? or css ?

help plz.

Comments

modul’s picture

You can put whatever php code you want in your template files, e.g. in "page.tpl.php" for things which need to occur on all pages, or in your node-your_content_type.tpl.php files for content-type specific stuff. You can also put php in a node, by enabling "php" in the input format (or whatever it's called). When you put php in a block, be careful, though, because 1 faulty php line can make your entire site inaccessible. So, always try your code in a node before putting it in a block.

David Stosik’s picture

I want to add that the template is not meant to contain PHP code which is not presentation.
May I ask you why you don't want to use a block?
Anyway, the solution I would suggest, if not using a PHP dynamic block, would be to write your own module (I generally name it my_project_name.module), and declare a module block and its callbacks.
Nevertheless, a Google AdSense module already exists, and I assume you already checked it.
If you no not want any block at all (no dynamic one, nor a module one), then I do not see any other mean than the template. Simply, be aware that this is not the good way to go, and that it is possible to display a block exactly the way you like...

David

modul’s picture

Hi Sto. You wrote that writing non-presentation PHP in a template is "not the good way to go". Umm, why not? I agree, if you want to write a template which is meant to be used on no matter what site, then it should not contain any 'business logic', but if the template only runs on your own site, then what's the problem if it includes 'business php'?

David Stosik’s picture

First, this will be hard to maintain.
Moreover, if you need to develop a new theme for the site, you will have to copy-paste this code in each template. Which leads to duplicate code, harder to maintain.
Lastly, this is the kind of piece of code that will be forgotten when upgrading Drupal, or modules, potentially causing some bugs...

warchucky’s picture

all i want to do is to put a googleadd banner on the LEFT side of my itheme (theme for drupal) i cant put blocks on the left, so i'll have to do it in php or template, thats my question, how can i do that, what code do i have to put at what location.