Magento – Adding CSS and JavaScript includes to the home page only
Posted on | February 3, 2012 | No Comments

There are many cases where you would only want to have certain styles or JavaScript includes within the homepage of your ecommerce site. Magento makes it as easy as modifying a single XML file to add these.
To add CSS or JavaScript includes to the hompage only open the -/app/design/frontend/default/{mytheme}/layout/cms.xml- file. Then find the line below.
<cms_index_index translate="label"> </cms_index_index>
It should be right around line 56. cms_index_index is equal to referencing the cms index controller with the request of the index action.
Within
To add a JavaScript document add the lines below then change the name and location to match that of the location of the file.
<action method="addJs"> <script>myjs/myscript.js</script> </action>
Adding CSS is done much the same way but the action method is changed to read -addCss-.
<action method="addCss">
<stylesheet>css/mystyle.css</stylesheet>
</action>
Your end result should look something like the image below.

Your included files should be stored within the -/skin/frontend/default/{mytheme}/- directory.
That’s all there is to it!
If you are not sure about setting up your own theme checkout a previous post!
Generating a new theme with Magento by using the default base theme
Posted on | February 2, 2012 | 1 Comment

Magento is one of the best freely available ecommerce solutions available today. It also happens to be based off of the Zend Framework.
Creating a new template is as simple as copying the default base theme install then modifying it to your liking. The theme system can get confusing as most external script and CSS includes are handled via layout XML files. Layout assignments are handled on a per controller action basis making modifications relatively easy and with most site-wide changes taking place within the page.xml or cms.xml these kind of changes can be made pretty rapidly.
Let begin by copying the files and directories within -/app/design/frontend/base/default/- to -/app/design/frontend/default/mytheme/-, whereas “mytheme” can be whatever you would like to call the new theme. Copying this directory will give you a full copy of the default front-end markup and styles within a Magento install. Next be sure to copy the base theme skin directory (/skin/frontend/base/default/) files to a new directory (/skin/frontend/default/mytheme/) sharing the name of your new theme.
Once you have completed copying the files you will then configure Magento to use the new themes location within the site admin. To do this login to your admin then browse to System->Configuration->General->Design->Themes. Once on this page configure it to look something like the image below.
Save your new settings then get to modifying your new theme XML, and PHTML files! Will cover more on Magento theming and plugin development later.
The best WordPress plugins – visibility – seo – functional
Posted on | January 30, 2012 | No Comments

WPTouch
Adds a mobile formatted version of your WordPress install for users that happen to browse to your website using a mobile device such as an iPhone, iPod, or Android device.
WP Realtime Sitemap
Provides an easy to install human readable HTML sitemap to whichever page or post you would like.
SEO Slugs
Automatically removes common words from your pages permalink. Words such as a, the, i, etc will automatically be removed giving you a shorter link with more related keywords instantly.
SEO Friendly Images
Automatically inserts image alt tags.
Greg’s High Performance SEO
Too many SEO features to mention. Install it. You will not be disappointed!
Google XML Sitemaps with qTranslate Support
Adds an XML sitemap to your blog to make it easier for search engine spiders to find your posts and pages.
Google XML Sitemap for Images
Creates an XML sitemap of all of the images within your blog.
Dublin Core for WordPress
Adds Dublin Core Meta tags to your header for posts and pages. More on Dublin Core here!
All in One Webmaster
Gives a simple interface for XML sitemap submission. Google, Bing, and Yahoo webmaster authentication, and Google Analytics account entry.
Zend Framework – Moving your database connection outside of the application.ini file
Posted on | January 29, 2012 | No Comments

Why would someone want to place their database connection settings within the unsecured application.ini configuration file? Why this is the default setting is beyond my own logic as it gives your users an open door to easily access and destroy your back office storage.
Moving your database configuration settings to an external PHP file is as simple as adding the two lines below to your bootstrap file.
protected function _initConfig(){
include_once(APP_BASE_PATH.'/application/configs/db.php');
$config = new Zend_Config($config);
return $config;
}
protected function _initDb(){
$this->bootstrap('config');
$config = $this->getResource('config');
$db = Zend_Db::factory($config->database);
Zend_Db_Table_Abstract::setDefaultAdapter($db);
Zend_Registry::set('db', $db);
return $db;
}
APP_BASE_PATH is a simple constant I configured within my index file in order to have an easily accessible string of the full directory structure to my application. There are many different ways to achieve this result but if you would like to use mine simply add the line below to your root index.php file.
// set application base path
define('APP_BASE_PATH',dirname(__FILE__));
Finally you will create a file named db.php within your /application/configs/ directory. This file will contain a multi-dimensional associative array containing your databases connection values. See the example below.
< ?PHP $config = array( 'database'=>array( 'adapter'=>'pdo_mysql', 'params'=>array( 'host'=>'localhost', 'dbname'=>'mydatabasename', 'username'=>'mydatabaseuser', 'password'=>'mydatabasepassword', ) ) );
That’s all you would to do to move your configuration file out of your application.ini file!
« go back — keep looking »

