brettbrewer.com

Programming + Design

Home
Apostrophe Trouble When Adding a Wordpress Feed to X-Cart PDF Print E-mail
Written by Brett Brewer   
Wednesday, 24 September 2008

Recently I ran into a very frustrating character encoding problem when trying to add a Wordpress feed display to X-Cart. I was using PHP's SimpleXML object to parse and display the feed in the home.tpl file in x-cart. The database and feed were in UTF-8 format and all the apostrophes and some other character codes were being converted into garbage when they were displayed in X-Cart's templates, but nowhere else. They looked fine in my feed readers and in the Wordpress templates. I initially blamed PHP's SimpleXML object, then LibXML, then decided it was Apache's fault or that the web host had misconfigured the server to force the character encoding to ISO-8859-1. After much troubleshooting and ranting, I finally realized that X-Cart's language settings were overriding the character encoding meta tag defined in the page template and forcing the browser to use ISO-8859-1 encoding. Apparently x-cart injects a character-encoding header into the output before it renders the Smarty templates, so even if you define the character set in your home.tpl file, or meta.tpl file, x-cart will still inject the character encoding defined for your default language into the HTTP headers via PHP's header() function. This isn't necessarily a bad thing, but it was extremely infuriating to track down and I think most template designers probably expect to be able to insert the character encoding into their templates manually and have it work. So to get my UTF-8 blog feed to display properly in X-Cart required going into the "Language" menu of the X-Cart admin area and changing the encoding setting for English to UTF-8. After years of using and modding X-Cart I've never needed to change this setting until today, but it's an important one to know about if you value your sanity.

Last Updated ( Wednesday, 24 September 2008 )
 
< Prev   Next >

Search

Who's Online


© 2017 www.brettbrewer.com
Joomla! is Free Software released under the GNU/GPL License.