I also redid my entire website with the latest version of my CMS and using Bootstrap. Please let me know if you encounter any issues.
]]>
I decided to find where in the code the error was coming from and make it work like it used to. My solution (and it may not be optimal as I didn't dig that deeply) is as follows:
1) Edit smarty/libs/sysplugins/smarty_internal_data.php and change the getVariable() function to:
/**
* gets the object of a Smarty variable
*
* @param string $variable the name of the Smarty variable
* @param object $_ptr optional pointer to data object
* @param boolean $search_parents search also in parent data
* @return object the object of the variable
*/
public function getVariable($_variable, $_ptr = null, $search_parents = true, $error_enable = true)
{
if ($_ptr === null) {
$_ptr = $this;
} while ($_ptr !== null) {
if (isset($_ptr->tpl_vars[$_variable])) {
// found it, return it
return $_ptr->tpl_vars[$_variable];
}
// not found, try at parent
if ($search_parents) {
$_ptr = $_ptr->parent;
} else {
$_ptr = null;
}
}
if (isset(Smarty::$global_tpl_vars[$_variable])) {
// found it, return it
return Smarty::$global_tpl_vars[$_variable];
}
if ($this->smarty->error_unassigned && $error_enable) {
throw new SmartyException('Undefined Smarty variable "' . $_variable . '"');
} else {
if (! $this->smarty->error_unassigned) {
return new Smarty_variable(null, false);
} else {
if ($error_enable) {
// force a notice
$x = $$_variable;
}
return new Undefined_Smarty_Variable;
}
}
}
2) Now in your code, before calling the template, add this line:
$smarty->error_unassigned = false;
This assumes your instance of Smarty is called $smarty. The beauty of this method is that you don't have to turn off ALL error messages just to suppress the missing var message.
]]>Six hours later (might be a slight exaggeration) I finally found the problem. The culprit was the following line in lib/setup.php:
raise_memory_limit('96M'); // We should never NEED this much but just in case...
]]>
I first want to clear up the difference between parameters and variables. A parameter is passed along with the request for a CSS file and can subsequently be referenced using the $_GET array (assuming you are using PHP). Variables are defined either in the CSS file or pulled in from the PHP environment variables. CSS files could potentially behave differently based on a value within a user's $_SESSION. This is a bad idea, and I will explain a little later.
In my dynamic CSS library, parameters become variables within the CSS file. The subtle difference has to do with browser caching. This is a common argument against using CSS variables since the browser has no knowledge of a variable's value and may return a cached version of the CSS file where the values were different than they are now. By using parameters, the values are part of the request itself and caching includes them. In other words:
returns a different browser cached version than:
]]>
To clarify the last bullet, I will give an example of the old syntax (which still works):
body
{
color: #000;
if ($_GET[‘theme’] == ‘blue’)
backgroundâ€color: #03C;
else
backgroundâ€color: #CCC;
endif
}
Now can be written on a single line:
body {
color: #000;
if ($_GET[‘theme’] == ‘blue’); backgroundâ€color: #03C; else; backgroundâ€color: #CCC; endif;
}
]]>Credit must be given to Csongor Zalatnai of Hungary for creating the original class.
]]>You can download version 1.1 here.
]]>The other nice thing about open source is, well, you get the source. Being a hands on type of programmer I get suspicious of "black box" solutions. I always suspect there is some programming bug lurking in there waiting to rise up and bite me. When my program isn't working is it because I did something wrong or am I hitting one of those nasty bugs in a vendor's package? I have done my share of "alpha testing" of a vendor's supposedly "production" code. Of course the burden of proof is always on you. Create your simple test case showing the bug and wait on the tech support hotline listening to Kenny G for hours only to end up talking to someone who just joined the company a week ago. I would much rather have all the code in front of me to dive in and fix whatever problem arises.
Ok, so now you are probably thinking "What's the problem"? The basic issue is that Open Source projects are also free. Believe me I love free. I am addicted to free. And therein lies the problem. There is so much Open Source code out there - and a lot of it really good quality, that people think all code should be free. The idea that I may want to charge for my time programming puts me into the greedy money grubbing capatilist ranks of Bill Gates. To see an extreme example of this sentiment, watch the movie "Antitrust" where an evil Tim Robbins resorts to murder to protect his investment in code. The message from the movie is "all code should be free"! So instead, many programmers decide to give away their code and add a "donate" button in hopes someone will realize the time and effort they put into developing the code and will compensate them for their time. Forget the fact you have bills to pay and mouths to feed.
This article is more of an expression of my frustration at how devalued programming skills have become. I guess this may be payback for the years of excessive fees paid to average or below average consultants. I have no great solution to this issue. I see some open soure projects have been adopting different approaches like "free for the basic functionality and then pay for either services or additional functionality". Time will tell approach works best.
]]>