Well, that looks like it should work, if you have set the parameters correctly.
You don't actually say what's going wrong, i.e. what result is being generated so it's a bit hard to tell exactly, so here's some background info and suggestions that may help you figure it out. For template development you can find more at the Joomla Docs website on Template Development.
Assuming your code is in your templates index.php
:
$this->params->get('sidebarLeftWidth','')
is getting a template parameter calledsidebarLeftWidth
, but if that parameter isn't available then it's setting it to''
effectivelynull
.The parameter names in your
get
should be defined with exactly the same spelling and capitalisation as in yourtemplateDetails.xml
file. If not your$left
and$right
may be empty. (It will help if you edit your question to include the template XML, or part of it.)The
params
part is a JRegistry object and returns a mixed type depending on what is originally stored in the name attribute of the object (usually this is a string, but it could be anything PHP can handle). To force an in value you may want to change yourget
lines to cast the results as integers and return 0 if nothing is found:$left = (int) $this->params->get('sidebarLeftWidth', 0);
$right = (int) $this->params->get('sidebarRightWidth', 0);
Check the contents of your
params
in your debugger, i.e. check the values of each of your named parameters in the$this->params
object. If you're not using an IDE try doing aprint_r()
:echo '<pre>' . print_r($this->params, true) . '</pre>';