Magento : find out which xml fails

If you’ve been working with Magento extensions or layout, you might have encountered the frustration of trying to find out which XML generates the following error, potentially harming the whole magento installation :

Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 61: parser error : StartTag: invalid element name  in C:\aa_work\RueDeSiam\www\lib\Varien\Simplexml\Config.php on line 502

#0 C:\aa_work\RueDeSiam\www\lib\Varien\Simplexml\Config.php(502): mageCoreErrorHandler(2, 'simplexml_load_...', 'C:\aa_work\RueD...', 502, Array)
#1 C:\aa_work\RueDeSiam\www\lib\Varien\Simplexml\Config.php(489): Varien_Simplexml_Config->loadString('?????? ...', 'Mage_Core_Model...')
#2 C:\aa_work\RueDeSiam\www\app\code\core\Mage\Adminhtml\Model\Config.php(102): Varien_Simplexml_Config->loadFile('?????? ...', 'Mage_Core_Model...')
#3 C:\aa_work\RueDeSiam\www\app\code\core\Mage\Adminhtml\Model\Config.php(63): Mage_Adminhtml_Model_Config->_initSectionsAndTabs('C:\aa_work\RueD...')
#4 C:\aa_work\RueDeSiam\www\app\code\core\Mage\Adminhtml\controllers\System\ConfigController.php(70): Mage_Adminhtml_Model_Config->getSections()
#5 C:\aa_work\RueDeSiam\www\app\code\core\Mage\Core\Controller\Varien\Action.php(367): Mage_Adminhtml_System_ConfigController->editAction(NULL)
#6 C:\aa_work\RueDeSiam\www\app\code\core\Mage\Core\Controller\Varien\Router\Admin.php(143): Mage_Core_Controller_Varien_Action->dispatch()
#7 C:\aa_work\RueDeSiam\www\app\code\core\Mage\Core\Controller\Varien\Front.php(158): Mage_Core_Controller_Varien_Router_Admin->match('edit')
#8 C:\aa_work\RueDeSiam\www\app\Mage.php(457): Mage_Core_Controller_Varien_Front->dispatch(Object(Mage_Core_Controller_Request_Http))
#9 C:\aa_work\RueDeSiam\www\index.php(66): Mage::run()
#10 {main}

the problem with this kind of error is that it doesn’t tell you which file is causing the error. To find out, work with your local installation

  • set the developer mode in index.php : Mage::setIsDeveloperMode(true);
  • open the app/code/core/Mage/Adminhtml/Model/Config.php and let the _initSectionsAndTabs tell you which xml is being loaded in the modules loop, just after $configFile is defined : echo $configFile;
  • the last file that pops before the error is thrown out is likely to cause the breakout !!

wp super cache and WP3.0 menus

For those who are running small servers and wish to accelerate their worpdress installation, we recommend the installation of eaccelerator but also the wp-super-cache plugin. There is just a small hack for wordpress 3.0 menu users : the cache should be totally refreshed when a menu is modified, and this is performed via the wp_update_nav_menu action, instantiated in the wp-cache-phase2.php / wp_cache_phase2 function

add_action("wp_update_nav_menu" , 'wp_cache_clear_cache' );

PHP development framework comparison : symfony, Zend Framework, Code Igniter

Before starting development on a new project, I need to investigate 3 popular PHP development frameworks. I would say if you need to choose, stick to the one you know already. I you don’t know a framework already then you’re in trouble and you need advice. Here a few things I would look for.

Beyond the code and standarts : what’s available

MVC is a nice idea but it’s only an idea and even if it’s useful to structure the code the power of frameworks are in their community.

  • Look for application samples.
    • Zend framework used to have a good application sample, distributed free as DodoApp. Unfortunately it’s not available any more but other applications are out there to get you started if you need code samples, check out our article. In general I have been looking a lot and it’s hard to find a starter application for Zend Framework
    • Symfony has a lot of opensource applications, the list is here
    • Code Igniter is simpler to learn apparently but you’ll find it hard to find good sample applications .We ‘ve listed two of them in a previous article
  • Look for available code snippets
    • Zend framework code snippets can be found all over the web but you have to know the framework really well to integrate them in your application
    • Code igniter snippets are displayed on the forum but not categorized
    • symfony snippets are organized and tagged in the plugin repository, easily available from Symfony’s official web site,  and I have to say that’s a real sign of good community work

The conclusion is make your life and your own choice. I was using Zend framework but a few minutes investigation convince me I should look into symfony.

Magento Configurable products : change product image on thumbnail option

This article describes a  color chooser for magento product page, a technique that automatically use product attributes from a Magento admin to display color thumbnails that

  • allows end user to choose color option by clicking on thumbnail
  • change product image to associated product image

the technique above is inspired from Magento Wiki page that describes the javascript that catches the Options price select event to modifyu the product image. We’ve changed a few things though

  1. Read the rest of this entry »

Publish wordpress posts to social networks

Header_Share

Worpdress is great for quick publishing and a variety of plugins are available that let users publish to various platforms. The image above, extracted from the gigya website, illustrates the versatily of social networks. Gigya itself provides a plugin for Wordpress. The technique is commonly described as cross posting, meaning one post on wordpress notifyes various social networks. Cross post plugins include:

  • WordBook : cross-post your blog posts to your Facebook Wall.
  • Same for wordbooker
  • Wordpress to myspace publishes  posts to myspace
  • Ping FM is a free  service that publishes posts to social networks. Wordpress has a few plugins that integrate with ping.fm, check this out

Statistics are an important part of social networking : no point developping web presence without knowing where you go

  • Facebook Share Stats : provides charts and numbers  on your posts shared on Facebook, with statistics and charts about the number of “like“, comments and clicks received.

Interesting links

Allow users to submit posts with wordpress

Besides the famous CFORMS plugins, opther plugins exist that forward user input directly to posts

  • TDO Mini Forms : comes with a lot of options that specify who can publish what and how new posts are moderated
  • FV Community News

Jquery wysiwyg editing

image.axd

Out of smart combination of powerful jquery plugins and functions comes the Minibar, contextual editing menu that pops up in windows Office 2007 fashion. The demo provided works with standard textarea editor but we’d like to see it implemented within tinymce or fckeditor, for instance : no doubt this is coming in the next few hours !!

CloudZoom : Jquery zoom enhanced

cloud-zoomCloudZoom, A new jquery zoom is here on the market, with features such as image blur, zooming inside the image. It works a bit like jqZoom, which is now a de facto standard for image zooming, but CloudZoom claims to be lighter and certainly is nicer to view.

http://www.professorcloud.com/mainsite/cloud-zoom.htm

Wordpress single install / multiple blogs

Yes it is possible to host multiple sites for multiple customers with Wordpress. The Multi User feature we expeted in wordpress 3.0 will satisfy bloggers only but we need something more specific. The technique I describe here is similar to the one described here in the sense that it directs the database configuration constants to specific databases instead of table prefixes as seen a lot. The advantage obviously is that you keep a single install of wordpress and only have one codebase to manage , while databases remain independant.

  • create wp-domains folder, and inside one folder for each domain, example wp-domains/mysite.com
  • add the following code to wp-config.php : this coding allows a defualt domain to remain active even when the configuration file does not exist, at the expense of a loss in performance. But It is useful to show what’s missing.

$domain = strtolower( str_replace( “www.”, “”, $_SERVER["SERVER_NAME"] ) );
$domain = preg_replace(’[^a-z0-9\.-]‘, ”, $domain );
$domainDirectory=”/wp-domains/” .$domain;
$domainConfig= dirname(__FILE__) . $domainDirectory . “/db-config.php”;
if ( file_exists( $domainConfig ) ) {require_once( $domainConfig );} else {
$dbuser=”defaultdomaindatabase”;
$dbpwd=”password”;
if ($domain!=”defaultdomain.com”) echo “missing ” .$domainConfig;}

  • replace definitions with variables in wp-config.php

define(’DB_NAME’, $dbuser);
define(’DB_USER’, $dbuser);
define(’DB_PASSWORD’, $dbpwd);

Once this is working with your default  domain, setup virtual hosts  in Apache and try a new domain. Remember on a new install to setup the upload folder in wordpress admin settings.

Multi site config for Wordpress : Compatible plugins

I’m running the following plugins and they work perfectly

  • WP Super Cache : works fine because the cache filename coding alogrithm includes the domain name

Wordpress : Upload images in post meta

verve-meta-boxes

Word press image upload is nice and perfectly integrated in the wysiwyg editor. If you need to specify clearly where the image will appear, you can use the post thumnbail feature that attaches a specific image to a post. But if you need to duisplay more than image per post, then you’re better off using custom fields, and a few plugins are available to let you upload image directly to a custom field

Bonus : Custom Field Template Hack  displays full size image on custom image thumbnail in post / page edit in backend and additional function to automate image display in templates

Read the rest of this entry »