[themes] Is there a better way to do this? (by "this", I mean
include javascript commands in the body of a page that change
in response to page.tpl.php variables)
Nick Lewis
nick at smartcampaigns.com
Thu Feb 2 22:40:18 UTC 2006
Rowan Kerr wrote:
> Nick Lewis wrote:
>
>> The problem is that sidebar-left only appears when the user is logged
>> in, and mission only appears on the front page.
>
>
> if ($is_front) { }
>
> global $user;
> if ($user->uid > 0) { }
>
Ah yes -- but you see this is a theme that I intend to release
publically, so I have to use non-site-specific variables (e.g. the
navigation block appearing on the left only for users). Here's what I
have so far (note that sidebar cases 1,2,3 are determined by a switch
script earlier in page.tpl.php -- I've included it below this script:
<?php if (module_exist('jstoolbox')) { ?>
<?php
print "<script>
";
print "var roundCorners = Rico.Corner.round.bind(Rico.Corner);
";
$curve_script .= "
roundCorners('main')" . ";
" .
"roundCorners('top-nav',{corners:'tl tr'})" . ";
";
if ($mission) {
$curve_script .= "
roundCorners('mission')" . ";
" ;
}
switch ($config) {
case 3:
$curve_script .= "roundCorners('sidebar-right',{
border:'#DFDFDF'})" . ";
" .
"roundCorners('sidebar-left',{border:'#DFDFDF'})" . ";
" ;
break;
case 2:
$curve_script .=
"roundCorners('sidebar-left',{border:'#DFDFDF'})". ";
";
break;
case 1:
$curve_script .=
"roundCorners('sidebar-right',{border:'#DFDFDF'})". ";
";
break;
}
$curve_script .= "
</script>";
print $curve_script;
?>
<?php } ?>
the other script:
<div id="main" class="<?php
/* Real world math to show to kids. Yeah.... */
if ($sidebar_right) {
$a = 1;
} else {
$a = 0;
}
if ($sidebar_left) {
$b = 2;
} else {
$b = 0;
}
$config = $a + $b;
switch ($config) {
case 3:
echo "show-all";
break;
case 2:
echo "hide-right";
break;
case 1:
echo "hide-left";
break;
default:
echo "hide-all";
}
?>">
>
>
> _______________________________________________
> themes mailing list
> themes at drupal.org
> http://lists.drupal.org/mailman/listinfo/themes
>
More information about the themes
mailing list