[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 21:01:44 UTC 2006
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
More information about the themes
mailing list