Okay, so I'm building this theme called curved_slate -- the first live knock off of it is at the Texas ISP association: http://www.tispa.org/
I'm using the prototype and rico javascript libraries to handle those rounded corners you see on the page. However, I'm having an issue with ordering the javascript that executes the rounded box code. Below, would be the correct ordering that follows the markup from top to bottom:
... <script> var roundCorners = Rico.Corner.round.bind(Rico.Corner);
roundCorners('main',{corners:"all"}); roundCorners('top-nav',{corners:"tr tl"}); roundCorners('mission'); roundCorners('sidebar-left',{border:"#DFDFDF"}); roundCorners('sidebar-right',{ border:"#DFDFDF"}); </script> </body> </html>
The problem is that sidebar-left only appears when the user is logged in, and mission only appears on the front page. When mission doesn't appear, but the javascript attempts to wrap it, the entire script ends, and sidebar-left, and right alike are left naked, cold, and without the sexy curves. My solution is going to be to use a php script to generate the javascript. I was thinking something along the lines of:
<?php if (insert variable to test if my jstoolbox module exists) { if ($mission) { $curveJS .= [mission javascript] } and so forth....
And better ways that anyone knows off the top of their head to do this?
Best, Nick Lewis http://nicklewis.smartcampaigns.com
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) { }
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@drupal.org http://lists.drupal.org/mailman/listinfo/themes
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).
Why are these variables site specific? $is_front is created by PHPTemplate, and I don't have to tell you where $user comes from.
Are you trying to define a "region"? 4.7 has these. Your theme could define a bunch of different regions and you could test
If ($region1) {} If ($region2) {} ... Etc
I guess I'm not understanding the problem.
-M
Nick Lewis wrote:
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).
Try the $layout variable for a 4.6 theme. (Has values of "left", "right", "both" .. I think).