Hi,
I like to give my users the option to change styles. Normally I do the following:
Above the doctype declaration I put:
[codebox]<?php
//{{{ function setStyleSheet($href, $title)
function setStyleSheet($href, $title) {
$groups = array('default', 'large', 'small');
$style = in_array($_COOKIE['style'], $groups) ? $_COOKIE['style'] : 'default';
$rel = ($style == $title) ? 'stylesheet' : 'alternate stylesheet';
return "\t<link type='text/css' rel='${rel}' href='${href}' title='${title}' />\n";
}
//}}}
?>
<?php ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
[/codebox]
Then in the <head> i put:
<?php
print setStyleSheet('/templates/bentley_beetham_template/mgh.css', 'default');
print setStyleSheet('/templates/bentley_beetham_template/largetext.css', 'large');
print setStyleSheet('/templates/bentley_beetham_template/textonly.css', 'small');
?>
Then in the <body> i put:
[codebox]<div id="accessnav">
<span class="label">Display Options</span>
<ul>
<li class="skipnav"><a href="#main" title="Skip navigation and go to content" tabindex="1">Skip to Content</a></li>
<li class="largetext"><a href="/styleswitch.php?s=large" title="large">Large Text</a></li>
<li class="textonly"><a href="/styleswitch.php?s=small" title="small">PDA / Text Only</a></li>
<li class="default"><a href="/styleswitch.php?s=default" title="default">Default</a></li>
</ul>
</div>[/codebox]
basically the scripts looks to see if the broswer has javascript enabled - if it does, it uses javascript to change the stylesheet, if not it resorts to serverside php switching.
When I add similar code to the phprunner pages I get a smarty error. How would I go about incorporating this into the template and in to the smarty coding.
I would be really grateful for any help on this.
Thanks in advance.
Ben