You can extract all of the variables in use from a Smarty template using a simple call to *nix grep with a trivial regex expression. Here is the command:
grep -o "\{\$[-_a-zA-Z0-9]*\}" my-template.tpl
You can extract all of the variables in use from a Smarty template using a simple call to *nix grep with a trivial regex expression. Here is the command:
grep -o "\{\$[-_a-zA-Z0-9]*\}" my-template.tpl
We recently moved away from phplist (goodbye phplist — we loved you for a while but now we need more power). Here is the SQL used to rip our users out of the main list. Attributes 1 and 2 are the first and last name.
SELECT DISTINCT phplist_user_user.email AS Email, phplist_user_user_attribute1.value AS FirstName, phplist_user_user_attribute2.value AS LastName FROM phplist_user_user JOIN phplist_user_user_attribute AS phplist_user_user_attribute1 ON ( phplist_user_user_attribute1.userid = phplist_user_user.id AND phplist_user_user_attribute1.attributeid = 1 ) JOIN phplist_user_user_attribute AS phplist_user_user_attribute2 ON ( phplist_user_user_attribute2.userid = phplist_user_user.id AND phplist_user_user_attribute2.attributeid = 2 ) JOIN phplist_listuser ON ( phplist_listuser.userid = phplist_user_user.id AND phplist_listuser.listid = 1 ) WHERE phplist_user_user.blacklisted = 0
Version 1.6 of Browser.php has been released with a lot of updates: http://chrisschuld.com/projects/browser-php-detecting-a-users-browser-from-php/
For those of you who detect Opera 10′s user agent, the Opera team has provide some “fun” for all of us. In my Browser project I started getting feedback that it was broken. At the 10,000′ level, it was defintely broken because the Browser project was returning version 9.8 for Opera version 10.
This is because the Opera dev team decided to leave the version 9.8 user agent string the same and tack on version 10 to end of the string. You can read more about it on their blog.
For those of you using my Browser project have no fear; the new version (1.6+) handles the oddity!
In the Browser.php project John pointed out (in the comments) a terrible typo in the source. I imagine no one has encountered this before as it only effects v1 or v1.5 of Internet Explorer.
Typo updated and version 1.5 of Browser.php released: http://chrisschuld.com/projects/browser-php-detecting-a-users-browser-from-php/
A while back I wrote a semi-popular post on removing images from a WordPress post — today I am revisiting it. The original solution used the_content() and the output buffer to remove the images out of the post. Now that I have used WordPress a bit longer and candidly had to use the solution again and thought “what was I thinking” I thought I would share the cleaner solution:
I released v1.4 of the Browser.php project today to address a few features suggested by readers. This new release adds support for GoogleBot, Yahoo! Slurp, and the W3C Validator.
Check out version 1.4: http://chrisschuld.com/projects/browser-php-detecting-a-users-browser-from-php/
Based on a comment on the Browser.php page I added support for the iPod today. I opted to place both the iPhone and iPod as browsers even though they are likely using the same instance of Safari. Additionally I added support for the iPod and iPhone as platforms. Thanks for the comments; enjoy!
The browser detection project in php (Browser.php) has been updated to version 1.2 based on suggestions I received in the comments. The new version is available for download in the project pages.
Thanks to all those who have emailed and commented on the script.
I updated the Browser.php class today to detect Google’s Chrome Browser. Additionally, thanks to an idea from Daniel ‘mavrick’ Lang, I added isBrowser($browserName) as a function to version 1.1.
Visit the Browser.php class page today to grab the update!
Interested in a PHP4 version? Daniel is maintaining a version for PHP4.
Example Usage:
$browser = new Browser();
if( ! ( $browser->getBrowser() == Browser::BROWSER_FIREFOX && $browser->getVersion() >= 2 ) ) {
echo 'You have FireFox version 2 or greater';
}
// AND NOW...
if( $browser->isBrowser(Browser::BROWSER_CHROME) ) {
echo 'Hi Google Chrome User!
';
}