Hiding certain code within the page.tpl.php when admin user is login

duvien - March 6, 2008 - 02:40

Hi,

I have a js code that is included in my page.tpl.php script and it works fine but it seems to have conflicts with some of the anchor tags used in the admin section. Therefore, i would like to hide the included js script in the HTML head of the page.tpl.php when logged in as any administrator user. Does anyone know how this can be achieved?
Or is this suppose to be done in the template.php file?

thanks,

Look at this

nijulay - March 11, 2008 - 18:27

Look at this http://drupal.org/node/52389
and http://drupal.org/node/46006 then you will get an idea.

<?php
function _phptemplate_variables($hook, $vars = array()) {
  switch (
$hook) {
    case
'page':
      if ((
arg(0) == 'admin')) {
       
$vars['template_file'] = 'page-admin';
      }
      break;
  }

  return
$vars;
}
?>

Thanks for that. I was

duvien - March 11, 2008 - 21:15

Thanks for that. I was aware you can do that but it is only for one page (ie, page-admin.tpl.php). What i wanted was to hide the js script for all pages that the admin is logged into (or each time you are logged in as admin browse any page of the site)?

------------------------------------------
Personal Blog & digital playground: duvien.com

"page-admin.tpl.php" is

dvessel - March 13, 2008 - 16:19

"page-admin.tpl.php" is already suggested by core. No need to add extra code for it.

joon park
–the devil in the details–

Actually, it's okay. I just

duvien - March 13, 2008 - 19:38

Actually, it's okay. I just needed this bit included in template.php:

....
  else if ((arg(0) == 'node')){
        if((arg(1) == 'add') || (arg(2) == 'edit')){
            $vars['template_file'] = 'page-admin';
        }
    }
...

Thanks for the link,

------------------------------------------
Personal Blog & digital playground: duvien.com

 
 

Drupal is a registered trademark of Dries Buytaert.