<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Mukesh Chapagain's Blog</title>
	
	<link>http://blog.chapagain.com.np</link>
	<description>PHP Magento jQuery Wordpress Javascript programming n tutorial</description>
	<lastBuildDate>Fri, 12 Mar 2010 13:16:15 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/chapagainblog" /><feedburner:info uri="chapagainblog" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId>chapagainblog</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><item>
		<title>Magento: Create Watermark Image</title>
		<link>http://feedproxy.google.com/~r/chapagainblog/~3/J5KDJ_LPwyA/</link>
		<comments>http://blog.chapagain.com.np/magento-create-watermark-image/#comments</comments>
		<pubDate>Fri, 12 Mar 2010 01:15:26 +0000</pubDate>
		<dc:creator>Mukesh</dc:creator>
				<category><![CDATA[Magento]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[watermark]]></category>

		<guid isPermaLink="false">http://blog.chapagain.com.np/?p=717</guid>
		<description><![CDATA[It&#8217;s very very easy to create watermark image with Magento code. The Varien_Image class does the magic.
The function watermark creates watermark on the image.

Here is the code:

$mainImage = Mage::getBaseDir('media') . DS . 'test' . DS . 'image.jpg';
$watermarkImage = Mage::getBaseDir('media') . DS . 'test' . DS . 'watermark.jpg';

$image = new Varien_Image($mainImage);

// set watermark image width
$image-&#62;setWatermarkWidth(100);

// set watermark image height
$image-&#62;setWatermarkHeigth(100);

// create watermark image
// watermark($watermarkImage, $positionX=0, $positionY=0, $watermarkImageOpacity=30, $repeat=false)
$image-&#62;watermark($watermarkImage);

// save the watermark image
$image-&#62;save(Mage::getBaseDir('media'). DS . 'test' . DS . 'new.jpg');

Code Explanation
In the code above, you can see that I have an image named ...


Related posts:<ol><li><a href='http://blog.chapagain.com.np/magento-get-width-height-of-image-using-varien_image-class/' rel='bookmark' title='Permanent Link: Magento: Get width height of image using Varien_Image class'>Magento: Get width height of image using Varien_Image class</a></li>
<li><a href='http://blog.chapagain.com.np/magento-resize-image/' rel='bookmark' title='Permanent Link: Magento: Resize Image'>Magento: Resize Image</a></li>
<li><a href='http://blog.chapagain.com.np/magento-custom-function-to-resize-image-proportionally/' rel='bookmark' title='Permanent Link: Magento: Custom function to resize image proportionally'>Magento: Custom function to resize image proportionally</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s very very easy to create watermark image with Magento code. The <strong>Varien_Image</strong> class does the magic.</p>
<p>The function <strong>watermark</strong> creates watermark on the image.</p>
<p><span id="more-717"></span></p>
<p>Here is the code:</p>
<pre class="brush: php;">
$mainImage = Mage::getBaseDir('media') . DS . 'test' . DS . 'image.jpg';
$watermarkImage = Mage::getBaseDir('media') . DS . 'test' . DS . 'watermark.jpg';

$image = new Varien_Image($mainImage);

// set watermark image width
$image-&gt;setWatermarkWidth(100);

// set watermark image height
$image-&gt;setWatermarkHeigth(100);

// create watermark image
// watermark($watermarkImage, $positionX=0, $positionY=0, $watermarkImageOpacity=30, $repeat=false)
$image-&gt;watermark($watermarkImage);

// save the watermark image
$image-&gt;save(Mage::getBaseDir('media'). DS . 'test' . DS . 'new.jpg');
</pre>
<p><strong>Code Explanation</strong></p>
<p>In the code above, you can see that I have an image named <strong>image.jpg</strong> inside <strong>media/test/</strong> directory.<br />
I have a watermark image named <strong>watermark.jpg</strong>.<br />
I have set the watermark image width and height to 100px. You can omit these two functions if you don&#8217;t want to resize the watermark image.<br />
The new image with watermark is saved inside <strong>media/test/</strong> directory as <strong>new.jpg</strong>.</p>
<p>Hope this helps and thanks for reading.</p>
<img src="http://blog.chapagain.com.np/?ak_action=api_record_view&id=717&type=feed" alt="" />

<p>Related posts:<ol><li><a href='http://blog.chapagain.com.np/magento-get-width-height-of-image-using-varien_image-class/' rel='bookmark' title='Permanent Link: Magento: Get width height of image using Varien_Image class'>Magento: Get width height of image using Varien_Image class</a></li>
<li><a href='http://blog.chapagain.com.np/magento-resize-image/' rel='bookmark' title='Permanent Link: Magento: Resize Image'>Magento: Resize Image</a></li>
<li><a href='http://blog.chapagain.com.np/magento-custom-function-to-resize-image-proportionally/' rel='bookmark' title='Permanent Link: Magento: Custom function to resize image proportionally'>Magento: Custom function to resize image proportionally</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.chapagain.com.np/magento-create-watermark-image/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blog.chapagain.com.np/magento-create-watermark-image/</feedburner:origLink></item>
		<item>
		<title>Chat in Devnagari with nepText Live Messenger Plugin</title>
		<link>http://feedproxy.google.com/~r/chapagainblog/~3/FaWSc8gZAJ0/</link>
		<comments>http://blog.chapagain.com.np/chat-in-devnagari-with-neptext-live-messenger-plugin/#comments</comments>
		<pubDate>Tue, 09 Mar 2010 12:47:29 +0000</pubDate>
		<dc:creator>Mukesh</dc:creator>
				<category><![CDATA[Review]]></category>
		<category><![CDATA[chat]]></category>
		<category><![CDATA[devnagari]]></category>
		<category><![CDATA[messenger]]></category>
		<category><![CDATA[nepText]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://blog.chapagain.com.np/?p=707</guid>
		<description><![CDATA[Do you use MSN Messenger and want to chat in Devnagari (Hindi, Nepali)? If your answer is YES then nepText plugin is just for you.
nepText is an MSN Messenger plugin that lets you to chat in both English and Devnagari.

Features
1. You can start typing in Devnagari (Nepali, Hindi) by simply pressing Ctrl + N. To switch back to English, again press Ctrl + N. Each words are converted to Devnagari when &#8220;Space&#8221; is pressed.

2. You can embed English words in between Devnagari as well. To do this, precede any words ...


Related posts:<ol><li><a href='http://blog.chapagain.com.np/wordpress-plugin-quick-adsense-10/' rel='bookmark' title='Permanent Link: Wordpress Plugin: Quick Adsense 1.0'>Wordpress Plugin: Quick Adsense 1.0</a></li>
<li><a href='http://blog.chapagain.com.np/new-wordpress-plugin-author-introduction/' rel='bookmark' title='Permanent Link: New Wordpress Plugin &#8211; Author Introduction'>New Wordpress Plugin &#8211; Author Introduction</a></li>
<li><a href='http://blog.chapagain.com.np/jquery-cool-bouncing-navigation-with-easing-plugin/' rel='bookmark' title='Permanent Link: jQuery: Cool Bouncing Navigation with easing plugin'>jQuery: Cool Bouncing Navigation with easing plugin</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Do you use MSN Messenger and want to chat in Devnagari (Hindi, Nepali)? If your answer is YES then <strong><a href="http://neptext.com/">nepText </a></strong>plugin is just for you.</p>
<p><strong><a href="http://neptext.com/">nepText </a></strong>is an MSN Messenger plugin that lets you to chat in both English and Devnagari.</p>
<p><span id="more-707"></span></p>
<p><strong>Features</strong></p>
<p>1. You can start typing in Devnagari (Nepali, Hindi) by simply pressing Ctrl + N. To switch back to English, again press Ctrl + N. Each words are converted to Devnagari when &#8220;Space&#8221; is pressed.</p>
<p><img class="alignnone" title="nepText" src="http://lh6.ggpht.com/_MtILEp64EVg/S5Y_-CrHNqI/AAAAAAAAAKw/z22sZcVIOrA/neptext1.jpg" alt="nepText" width="479" height="387" /></p>
<p>2. You can embed English words in between Devnagari as well. To do this, precede any words with a forward slash,&#8221;/&#8221;, or put several words inside square brackets,&#8221;[]&#8220;. Any words that is preceded by a forward slash or are inside square brackets are not converted and appear as they are.</p>
<p><img class="alignnone" title="nepText" src="http://lh5.ggpht.com/_MtILEp64EVg/S5Y_-Md6VvI/AAAAAAAAAK0/EuHLvmq2NJM/neptext2.jpg" alt="nepText" width="616" height="452" /></p>
<p>3. It supports emoticons :). You can send emoticons even when you are chatting in Devnagari (Nepali, Hindi).</p>
<p><strong>Installation</strong></p>
<p>1. Unzip the downloaded zip file from <a href="http://neptext.com"><strong>nepText Download site</strong></a></p>
<p>2. Double click neptext.exe</p>
<p>3. Follow steps that appear in the new window.</p>
<p>You can find a <strong>help file </strong>in the zip package. It contains detail information about Installing neptext, its Features, and Mappings.</p>
<p>It&#8217;s really a cool plugin that makes life easy ;)</p>
<p>Have fun!</p>
<img src="http://blog.chapagain.com.np/?ak_action=api_record_view&id=707&type=feed" alt="" />

<p>Related posts:<ol><li><a href='http://blog.chapagain.com.np/wordpress-plugin-quick-adsense-10/' rel='bookmark' title='Permanent Link: Wordpress Plugin: Quick Adsense 1.0'>Wordpress Plugin: Quick Adsense 1.0</a></li>
<li><a href='http://blog.chapagain.com.np/new-wordpress-plugin-author-introduction/' rel='bookmark' title='Permanent Link: New Wordpress Plugin &#8211; Author Introduction'>New Wordpress Plugin &#8211; Author Introduction</a></li>
<li><a href='http://blog.chapagain.com.np/jquery-cool-bouncing-navigation-with-easing-plugin/' rel='bookmark' title='Permanent Link: jQuery: Cool Bouncing Navigation with easing plugin'>jQuery: Cool Bouncing Navigation with easing plugin</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.chapagain.com.np/chat-in-devnagari-with-neptext-live-messenger-plugin/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://blog.chapagain.com.np/chat-in-devnagari-with-neptext-live-messenger-plugin/</feedburner:origLink></item>
		<item>
		<title>Book Review: Magento 1.3: PHP Developer’s Guide</title>
		<link>http://feedproxy.google.com/~r/chapagainblog/~3/VbQGzAUGqf8/</link>
		<comments>http://blog.chapagain.com.np/book-review-magento-1-3-php-developers-guide/#comments</comments>
		<pubDate>Mon, 08 Mar 2010 13:04:43 +0000</pubDate>
		<dc:creator>Mukesh</dc:creator>
				<category><![CDATA[Magento]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Review]]></category>
		<category><![CDATA[book-review]]></category>

		<guid isPermaLink="false">http://blog.chapagain.com.np/?p=697</guid>
		<description><![CDATA[
PACKT Publishing has published a very useful Magento Developer Guide. This book has practical tutorials with examples. This book will be very useful for PHP Programmers who want to learn Magento architecture, extend the system and add new features to it.

I&#8217;ll be reviewing the book very soon.
View detail information about the book
Here are some of the prominent features of the book:-
1) Install and upgrade Magento to get ready for development
2) Get familiar with the architecture and internal structure of Magento
3) Learn about the best modules available and what they can ...


Related posts:<ol><li><a href='http://blog.chapagain.com.np/magento-get-store-information/' rel='bookmark' title='Permanent Link: Magento: Get store information'>Magento: Get store information</a></li>
<li><a href='http://blog.chapagain.com.np/magento-load-store-specific-product/' rel='bookmark' title='Permanent Link: Magento: Load store specific product'>Magento: Load store specific product</a></li>
<li><a href='http://blog.chapagain.com.np/magento-how-to-set-and-get-registry/' rel='bookmark' title='Permanent Link: Magento: How to set and get registry?'>Magento: How to set and get registry?</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p class="alignleft" style="text-align: left; margin: 5px; float: left;"><a href="http://www.packtpub.com/magento-1-3-php-developers-guide/book?utm_source=blog.chapagain.com.np&amp;utm_medium=link&amp;utm_content=blog&amp;utm_campaign=mdb_002668#indetail"><img class="alignnone" title="Magento 1.3: PHP Developer's Guide " src="http://lh4.ggpht.com/_MtILEp64EVg/S5T221IAFNI/AAAAAAAAAKQ/EM9_lBYNooc/MAGENTO-2.jpg" /></a></p>
<p>PACKT Publishing has published a very useful <a href="http://www.packtpub.com/magento-1-3-php-developers-guide/book?utm_source=blog.chapagain.com.np&amp;utm_medium=link&amp;utm_content=blog&amp;utm_campaign=mdb_002668#indetail"><strong>Magento Developer Guide</strong></a>. This book has practical tutorials with examples. This book will be very useful for PHP Programmers who want to learn Magento architecture, extend the system and add new features to it.</p>
<p><span id="more-697"></span></p>
<p><strong>I&#8217;ll be reviewing the book very soon.</strong></p>
<p><a href="http://www.packtpub.com/magento-1-3-php-developers-guide/book?utm_source=blog.chapagain.com.np&amp;utm_medium=link&amp;utm_content=blog&amp;utm_campaign=mdb_002668#indetail"><strong>View detail information about the book</strong></a></p>
<p>Here are some of the prominent features of the book:-</p>
<p>1) Install and upgrade Magento to get ready for development<br />
2) Get familiar with the architecture and internal structure of Magento<br />
3) Learn about the best modules available and what they can do for you out of the box<br />
4) Build a Shipping module for your Magento store to give users options for receiving their items once they have paid for them<br />
5) Create a payment method for Magento and the various aspects that go together to complete the payment process<br />
6) Speed up your module creation process using the Module Creator script<br />
7) Build a basic brand-management module for Magento to manage brands and display their details<br />
8) Integrate your favorite CMS into Magento including a walkthrough of integrating Wordpress into Magento<br />
9) Create, update, delete, and retrieve customer data from within Magento by implementing the customer API<br />
10) Integrate Magento data into an existing external web application or script using the Magento Core API<br />
11) Import/export files to retrieve and store information from and to external sources using Excel Spreadsheet or CSV data</p>
<p><a href="http://www.packtpub.com/magento-1-3-php-developers-guide/book?utm_source=blog.chapagain.com.np&amp;utm_medium=link&amp;utm_content=blog&amp;utm_campaign=mdb_002668#indetail"><strong>View detail information about the book</strong></a></p>
<p>Cheers,</p>
<img src="http://blog.chapagain.com.np/?ak_action=api_record_view&id=697&type=feed" alt="" />

<p>Related posts:<ol><li><a href='http://blog.chapagain.com.np/magento-get-store-information/' rel='bookmark' title='Permanent Link: Magento: Get store information'>Magento: Get store information</a></li>
<li><a href='http://blog.chapagain.com.np/magento-load-store-specific-product/' rel='bookmark' title='Permanent Link: Magento: Load store specific product'>Magento: Load store specific product</a></li>
<li><a href='http://blog.chapagain.com.np/magento-how-to-set-and-get-registry/' rel='bookmark' title='Permanent Link: Magento: How to set and get registry?'>Magento: How to set and get registry?</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.chapagain.com.np/book-review-magento-1-3-php-developers-guide/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blog.chapagain.com.np/book-review-magento-1-3-php-developers-guide/</feedburner:origLink></item>
		<item>
		<title>Solution: Google Adsense not showing on my website blog</title>
		<link>http://feedproxy.google.com/~r/chapagainblog/~3/Pfw87g6BOvY/</link>
		<comments>http://blog.chapagain.com.np/solution-google-adsense-not-showing-on-my-website-blog/#comments</comments>
		<pubDate>Thu, 25 Feb 2010 17:06:36 +0000</pubDate>
		<dc:creator>Mukesh</dc:creator>
				<category><![CDATA[Google]]></category>
		<category><![CDATA[Make Money Online]]></category>
		<category><![CDATA[ads]]></category>
		<category><![CDATA[adsense]]></category>
		<category><![CDATA[money]]></category>

		<guid isPermaLink="false">http://blog.chapagain.com.np/?p=693</guid>
		<description><![CDATA[
I used to have google adsense in my blog but they suddenly disappeared these days. I don&#8217;t see the adsense in my blog. Instead, I see ads stating &#8216;Microfinance Empowers&#8216; in some of my adsense block. Others are empty.
I googled the web and found the following cause and solution:-

Problem:
I used to have adsense showing in my website and blogs but I use to have adsense showing on my website and blogs but recently they don&#8217;t show on websites again instead what i see is this their microfinance stuff &#8220;Microfinance Empowers&#8221;.
Cause:
Since ...


Related posts:<ol><li><a href='http://blog.chapagain.com.np/how-to-setup-google-adsense-in-your-website/' rel='bookmark' title='Permanent Link: How to setup Google AdSense for your website'>How to setup Google AdSense for your website</a></li>
<li><a href='http://blog.chapagain.com.np/google-is-retiring-adsense-referrals/' rel='bookmark' title='Permanent Link: Google is retiring AdSense Referrals'>Google is retiring AdSense Referrals</a></li>
<li><a href='http://blog.chapagain.com.np/wordpress-plugin-quick-adsense-10/' rel='bookmark' title='Permanent Link: Wordpress Plugin: Quick Adsense 1.0'>Wordpress Plugin: Quick Adsense 1.0</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">
I used to have google adsense in my blog but they suddenly disappeared these days. I don&#8217;t see the adsense in my blog. Instead, I see ads stating &#8216;<strong>Microfinance Empowers</strong>&#8216; in some of my adsense block. Others are empty.</p>
<p>I googled the web and found the following cause and solution:-</p>
<p><span id="more-693"></span></p>
<p><strong>Problem:</strong></p>
<p>I used to have adsense showing in my website and blogs but I use to have adsense showing on my website and blogs but recently they don&#8217;t show on websites again instead what i see is this their microfinance stuff &#8220;Microfinance Empowers&#8221;.</p>
<p><strong>Cause:</strong></p>
<p>Since April 2009 it has been a term of service that Adsense publishers have a data protection compliant privacy policy on their site(s). Those who do not have such a policy often find that their ads turn to public service ads.</p>
<p><strong>Solution:</strong></p>
<p>In your <a href="https://www.google.com/adsense/report/overview">adsense report page</a>, you will see the following text highlighted in red:</p>
<blockquote><p>Your pages are displaying Public Service Advertisements (PSAs) because you haven&#8217;t yet verified your PIN and/or phone number. See the Payment History page for more details.</p></blockquote>
<p>You should verify your PIN Information in order to show adsense like before.</p>
<p>Login to your adsense account and go to this link: <a href="https://www.google.com/adsense/account-settings">https://www.google.com/adsense/account-settings</a></p>
<p>You will see the following notification about <strong>PIN Information</strong> highlighted in red:</p>
<blockquote><p>As part of our effort to protect the accounts of AdSense publishers, we have mailed a Personal Identification Number (PIN) to the payment address entered in your account. This PIN must be entered on the PIN Information page before any payments can be issued to you.</p>
<p>In the meantime, your account remains active, and you may continue to show ads and accrue earnings. If you have not received your PIN within 3 weeks, you may request that it be resent.</p>
<p>Please use the link below to enter your PIN or to request a reissue:<br />
PIN Information page</p></blockquote>
<p>Google will mail Personal Identification Number (PIN) to the payment address entered in your account.</p>
<p>You can request PIN from this link: <a href="https://www.google.com/adsense/pinentry">https://www.google.com/adsense/pinentry</a></p>
<p>Be sure that you have correct <strong>Payee information</strong> entered. You can edit Payee information from this link: <a href="https://www.google.com/adsense/account-edit">https://www.google.com/adsense/account-edit</a></p>
<p>The PIN information for your account will be mailed to you by google within <strong>3-6 weeks</strong> after your request for PIN.</p>
<p>When you get the PIN card sent to you by Google, you can enter the PIN in the <strong>PIN Entry</strong> section of this page: <a href="https://www.google.com/adsense/pinentry">https://www.google.com/adsense/pinentry</a></p>
<p>After that, you can see adsense in your site as before.</p>
<p>Hope this helps and thanks for reading.</p>
<img src="http://blog.chapagain.com.np/?ak_action=api_record_view&id=693&type=feed" alt="" />

<p>Related posts:<ol><li><a href='http://blog.chapagain.com.np/how-to-setup-google-adsense-in-your-website/' rel='bookmark' title='Permanent Link: How to setup Google AdSense for your website'>How to setup Google AdSense for your website</a></li>
<li><a href='http://blog.chapagain.com.np/google-is-retiring-adsense-referrals/' rel='bookmark' title='Permanent Link: Google is retiring AdSense Referrals'>Google is retiring AdSense Referrals</a></li>
<li><a href='http://blog.chapagain.com.np/wordpress-plugin-quick-adsense-10/' rel='bookmark' title='Permanent Link: Wordpress Plugin: Quick Adsense 1.0'>Wordpress Plugin: Quick Adsense 1.0</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.chapagain.com.np/solution-google-adsense-not-showing-on-my-website-blog/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://blog.chapagain.com.np/solution-google-adsense-not-showing-on-my-website-blog/</feedburner:origLink></item>
		<item>
		<title>Magento: Custom function to resize image proportionally</title>
		<link>http://feedproxy.google.com/~r/chapagainblog/~3/714vST2RQfs/</link>
		<comments>http://blog.chapagain.com.np/magento-custom-function-to-resize-image-proportionally/#comments</comments>
		<pubDate>Wed, 24 Feb 2010 12:39:49 +0000</pubDate>
		<dc:creator>Mukesh</dc:creator>
				<category><![CDATA[Magento]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[resize]]></category>

		<guid isPermaLink="false">http://blog.chapagain.com.np/?p=683</guid>
		<description><![CDATA[In my previous article to resize image in Magento, I had written direct code to resize any image. Here, I will be writing a simple function to resize image proportionally, which can be kept in the helper file of the module (as helper file can be accessed by any template (.phtml) file).
Well, the function credit goes to my friend Subesh&#8217;s article. He has already written such function in his blog article. I am just re-writing the function with some modifications (Making it easier for me to understand :))

Ok, here is ...


Related posts:<ol><li><a href='http://blog.chapagain.com.np/magento-resize-image/' rel='bookmark' title='Permanent Link: Magento: Resize Image'>Magento: Resize Image</a></li>
<li><a href='http://blog.chapagain.com.np/magento-get-width-height-of-image-using-varien_image-class/' rel='bookmark' title='Permanent Link: Magento: Get width height of image using Varien_Image class'>Magento: Get width height of image using Varien_Image class</a></li>
<li><a href='http://blog.chapagain.com.np/magento-create-watermark-image/' rel='bookmark' title='Permanent Link: Magento: Create Watermark Image'>Magento: Create Watermark Image</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>In my previous article to <a href="http://blog.chapagain.com.np/magento-resize-image/">resize image in Magento</a>, I had written direct code to resize any image. Here, I will be writing a simple function to resize image proportionally, which can be kept in the <strong>helper file</strong> of the module (as helper file can be accessed by any <strong>template (.phtml) file</strong>).</p>
<p>Well, the function credit goes to my friend <a href="http://subesh.com.np/2009/11/image-resize-magento-cache-resized-image/">Subesh&#8217;s article</a>. He has already written such function in his blog article. I am just re-writing the function with some modifications (Making it easier for me to understand :))</p>
<p><span id="more-683"></span></p>
<p>Ok, here is the custom image resize function. This function will resize image proportionally.</p>
<pre class="brush: php;">
/**
 * Resize Image proportionally and return the resized image url
 *
 * @param string $imageName	        name of the image file
 * @param integer|null $width 		resize width
 * @param integer|null $height 		resize height
 * @param string|null $imagePath 	directory path of the image present inside media directory
 * @return string 				full url path of the image
 */
public function resizeImage($imageName, $width=NULL, $height=NULL, $imagePath=NULL)
{
	$imagePath = str_replace(&quot;/&quot;, DS, $imagePath);
	$imagePathFull = Mage::getBaseDir('media') . DS . $imagePath . DS . $imageName;

	if($width == NULL &amp;&amp; $height == NULL) {
		$width = 100;
		$height = 100;
	}
	$resizePath = $width . 'x' . $height;
	$resizePathFull = Mage::getBaseDir('media') . DS . $imagePath . DS . $resizePath . DS . $imageName;

	if (file_exists($imagePathFull) &amp;&amp; !file_exists($resizePathFull)) {
		$imageObj = new Varien_Image($imagePathFull);
		$imageObj-&gt;constrainOnly(TRUE);
		$imageObj-&gt;keepAspectRatio(TRUE);
		$imageObj-&gt;resize($width,$height);
		$imageObj-&gt;save($resizePathFull);
	}

	$imagePath=str_replace(DS, &quot;/&quot;, $imagePath);
	return Mage::getBaseUrl(&quot;media&quot;) . $imagePath . &quot;/&quot; . $resizePath . &quot;/&quot; . $imageName;
}
</pre>
<p>You can write the following code in template (.phtml) file to display the resized image:</p>
<pre class="brush: php;">
&lt;img src=&quot;&lt;?php echo Mage::helper('moduleName')-&gt;resizeImage('abc.jpg', 400, 300, 'xyz/image'); ?&gt;&quot; alt=&quot;resized image&quot; /&gt;
</pre>
<p>Here, </p>
<p><strong>$imageName</strong> is the name of the image (e.g. abc.jpg)</p>
<p><strong>$width</strong> is the image resize width (e.g. 400)<br />
<strong>$height</strong> is the image resize height (e.g. 300)<br />
(400 resembles 400px and 300 resembles 300px)</p>
<p><strong>$imagePath</strong> is the path where the image is stored/saved. This directory must be inside &#8216;media&#8217; directory. Like, if we specify &#8216;<strong>xyz/image</strong>&#8216; as $imagePath then our image path must be &#8216;<strong>media/xyz/image/abc.jpg</strong>&#8216; (the $imageName is abc.jpg)</p>
<p>We have defined the width and height to be 400 and 300 respectively. So, a new folder will be created named &#8216;400&#215;300&#8242;. The new resized image will be saved here.</p>
<p>If width is null and height is 300 then the image will be resized proportionally with fixed height of 300px. And the folder name will be &#8216;x300&#8242;.</p>
<p>If width is 400 and height is null then the image will be resized proportionally with fixed width of 400px. And the folder name will be &#8216;400x&#8217;.</p>
<p>If both width and height are null then the image is resized with height &#8216;100&#8242; and width &#8216;100&#8242;. And the folder name will be &#8216;100&#215;100&#8242;.</p>
<p>Cheers,</p>
<img src="http://blog.chapagain.com.np/?ak_action=api_record_view&id=683&type=feed" alt="" />

<p>Related posts:<ol><li><a href='http://blog.chapagain.com.np/magento-resize-image/' rel='bookmark' title='Permanent Link: Magento: Resize Image'>Magento: Resize Image</a></li>
<li><a href='http://blog.chapagain.com.np/magento-get-width-height-of-image-using-varien_image-class/' rel='bookmark' title='Permanent Link: Magento: Get width height of image using Varien_Image class'>Magento: Get width height of image using Varien_Image class</a></li>
<li><a href='http://blog.chapagain.com.np/magento-create-watermark-image/' rel='bookmark' title='Permanent Link: Magento: Create Watermark Image'>Magento: Create Watermark Image</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.chapagain.com.np/magento-custom-function-to-resize-image-proportionally/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blog.chapagain.com.np/magento-custom-function-to-resize-image-proportionally/</feedburner:origLink></item>
		<item>
		<title>Magento: Easily add breadcrumbs to any page</title>
		<link>http://feedproxy.google.com/~r/chapagainblog/~3/9HsGzMNy928/</link>
		<comments>http://blog.chapagain.com.np/magento-easily-add-breadcrumbs-to-any-page/#comments</comments>
		<pubDate>Sat, 20 Feb 2010 04:15:14 +0000</pubDate>
		<dc:creator>Mukesh</dc:creator>
				<category><![CDATA[Magento]]></category>
		<category><![CDATA[breadcrumbs]]></category>
		<category><![CDATA[url]]></category>

		<guid isPermaLink="false">http://blog.chapagain.com.np/?p=579</guid>
		<description><![CDATA[Breadcrumbs are very useful for user navigation. Breadcrumbs for product page, category page, etc. are created by default Magento code.
The following code will show breadcrumbs created by Magento. You can print the following code anywhere in php or phtml files.


echo $this-&#62;getLayout()-&#62;getBlock('breadcrumbs')-&#62;toHtml();

You can create you own breadcrumbs as well. Like, you may need to create breadcrumbs if you have your own custom built module. I will show you here, how you can do it. 
It&#8217;s simple and easy. At first, you will define the breadcrumbs block. Then, you will add label, ...


Related posts:<ol><li><a href='http://blog.chapagain.com.np/magento-setchange-page-layout-title-tag-meta-keywords-and-description/' rel='bookmark' title='Permanent Link: Magento: Set/Change page layout, title tag, meta keywords and description'>Magento: Set/Change page layout, title tag, meta keywords and description</a></li>
<li><a href='http://blog.chapagain.com.np/magento-get-current-url-of-the-page/' rel='bookmark' title='Permanent Link: Magento: Get current Url of the page'>Magento: Get current Url of the page</a></li>
<li><a href='http://blog.chapagain.com.np/magento-get-country-and-region-collection/' rel='bookmark' title='Permanent Link: Magento: Get country and region collection'>Magento: Get country and region collection</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Breadcrumbs are very useful for user navigation. Breadcrumbs for product page, category page, etc. are created by default Magento code.</p>
<p>The following code will show breadcrumbs created by Magento. You can print the following code anywhere in php or phtml files.</p>
<p><span id="more-579"></span></p>
<pre class="brush: php;">
echo $this-&gt;getLayout()-&gt;getBlock('breadcrumbs')-&gt;toHtml();
</pre>
<p>You can create you own breadcrumbs as well. Like, you may need to create breadcrumbs if you have your own custom built module. I will show you here, how you can do it. </p>
<p>It&#8217;s simple and easy. At first, you will define the breadcrumbs block. Then, you will add label, title and link to your breadcrumbs. The <strong>addCrumb </strong>Magento function is used in this case.</p>
<pre class="brush: php;">
$breadcrumbs = $this-&gt;getLayout()-&gt;getBlock('breadcrumbs');

$breadcrumbs-&gt;addCrumb('home', array('label'=&gt;Mage::helper('cms')-&gt;__('Home'), 'title'=&gt;Mage::helper('cms')-&gt;__('Home Page'), 'link'=&gt;Mage::getBaseUrl()));

$breadcrumbs-&gt;addCrumb('country', array('label'=&gt;'Country', 'title'=&gt;'All Countries', 'link'=&gt;'http://example.com/magento/moduleName/country'));

$breadcrumbs-&gt;addCrumb('manufacturer', array('label'=&gt;'State', 'title'=&gt;'States'));
</pre>
<p>The label, title and link can be changed according to your need and requirement.</p>
<img src="http://blog.chapagain.com.np/?ak_action=api_record_view&id=579&type=feed" alt="" />

<p>Related posts:<ol><li><a href='http://blog.chapagain.com.np/magento-setchange-page-layout-title-tag-meta-keywords-and-description/' rel='bookmark' title='Permanent Link: Magento: Set/Change page layout, title tag, meta keywords and description'>Magento: Set/Change page layout, title tag, meta keywords and description</a></li>
<li><a href='http://blog.chapagain.com.np/magento-get-current-url-of-the-page/' rel='bookmark' title='Permanent Link: Magento: Get current Url of the page'>Magento: Get current Url of the page</a></li>
<li><a href='http://blog.chapagain.com.np/magento-get-country-and-region-collection/' rel='bookmark' title='Permanent Link: Magento: Get country and region collection'>Magento: Get country and region collection</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.chapagain.com.np/magento-easily-add-breadcrumbs-to-any-page/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blog.chapagain.com.np/magento-easily-add-breadcrumbs-to-any-page/</feedburner:origLink></item>
		<item>
		<title>Magento: How to upload file?</title>
		<link>http://feedproxy.google.com/~r/chapagainblog/~3/qcRwkxOGWXo/</link>
		<comments>http://blog.chapagain.com.np/magento-how-to-upload-file/#comments</comments>
		<pubDate>Fri, 19 Feb 2010 04:15:42 +0000</pubDate>
		<dc:creator>Mukesh</dc:creator>
				<category><![CDATA[Magento]]></category>
		<category><![CDATA[file]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[upload]]></category>

		<guid isPermaLink="false">http://blog.chapagain.com.np/?p=587</guid>
		<description><![CDATA[In adminhtml, you might have the following code in any form. Here &#8216;logo&#8216; is the name of the input type file. Or, you may have any HTML Form with the File field in the frontend page. Remember that your form&#8217;s enctype should be multipart/form-data. 

$fieldset-&#62;addField('logo', 'file', array(
	'label'     =&#62; 'Small Logo',
	'required'  =&#62; false,
	'name'      =&#62; 'logo',
));


You can easily upload file using Varien_File_Uploader class. The class file path is lib/Varien/File/Uploader.php.
- In the code below, the file field name is &#8216;logo&#8216;.
- You can add ...


Related posts:<ol><li><a href='http://blog.chapagain.com.np/file-upload-in-php-simplified/' rel='bookmark' title='Permanent Link: File Upload in PHP :: Simplified'>File Upload in PHP :: Simplified</a></li>
<li><a href='http://blog.chapagain.com.np/multiple-file-upload-with-jquery-and-php/' rel='bookmark' title='Permanent Link: Multiple file upload with jQuery and php'>Multiple file upload with jQuery and php</a></li>
<li><a href='http://blog.chapagain.com.np/magento-create-watermark-image/' rel='bookmark' title='Permanent Link: Magento: Create Watermark Image'>Magento: Create Watermark Image</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>In adminhtml, you might have the following code in any form. Here &#8216;<strong>logo</strong>&#8216; is the name of the input type file. Or, you may have any HTML Form with the File field in the frontend page. Remember that your form&#8217;s <strong>enctype </strong>should be <strong>multipart/form-data</strong>. </p>
<pre class="brush: php;">
$fieldset-&gt;addField('logo', 'file', array(
	'label'     =&gt; 'Small Logo',
	'required'  =&gt; false,
	'name'      =&gt; 'logo',
));
</pre>
<p><span id="more-587"></span></p>
<p>You can easily upload file using <strong>Varien_File_Uploader</strong> class. The class file path is <strong>lib/Varien/File/Uploader.php</strong>.</p>
<p>- In the code below, the file field name is &#8216;<strong>logo</strong>&#8216;.<br />
- You can add or remove allowed extension for upload through <strong>setAllowedExtensions </strong>function.<br />
- If <strong>setAllowRenameFiles </strong>function&#8217;s parameter is set true, then the uploaded file name will be changed if some file with the same name already exists in the destination directory.<br />
- The file is uploaded in <strong>media </strong>directory. You can add your own directory there. But remember that your directory should be writable.<br />
- save function is used to save the file with a specific name and to a specific path.</p>
<pre class="brush: php;">
if (isset($_FILES['logo']['name']) &amp;&amp; $_FILES['logo']['name'] != '') {
	try {
		$uploader = new Varien_File_Uploader('logo');
		$uploader-&gt;setAllowedExtensions(array('jpg','jpeg','gif','png'));
		$uploader-&gt;setAllowRenameFiles(false);
		$uploader-&gt;setFilesDispersion(false);
		$path = Mage::getBaseDir('media') . DS;
		// $path = Mage::getBaseDir('media') . DS . 'logo' . DS;
		$logoName = $_FILES['logo']['name'];
		$uploader-&gt;save($path, $logoName);

	} catch (Exception $e) {

	}
}
</pre>
<p>Hope this helps. Thanks for reading.</p>
<img src="http://blog.chapagain.com.np/?ak_action=api_record_view&id=587&type=feed" alt="" />

<p>Related posts:<ol><li><a href='http://blog.chapagain.com.np/file-upload-in-php-simplified/' rel='bookmark' title='Permanent Link: File Upload in PHP :: Simplified'>File Upload in PHP :: Simplified</a></li>
<li><a href='http://blog.chapagain.com.np/multiple-file-upload-with-jquery-and-php/' rel='bookmark' title='Permanent Link: Multiple file upload with jQuery and php'>Multiple file upload with jQuery and php</a></li>
<li><a href='http://blog.chapagain.com.np/magento-create-watermark-image/' rel='bookmark' title='Permanent Link: Magento: Create Watermark Image'>Magento: Create Watermark Image</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.chapagain.com.np/magento-how-to-upload-file/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://blog.chapagain.com.np/magento-how-to-upload-file/</feedburner:origLink></item>
		<item>
		<title>Magento: How to set and get registry?</title>
		<link>http://feedproxy.google.com/~r/chapagainblog/~3/StaIAnoBXXQ/</link>
		<comments>http://blog.chapagain.com.np/magento-how-to-set-and-get-registry/#comments</comments>
		<pubDate>Thu, 18 Feb 2010 04:15:08 +0000</pubDate>
		<dc:creator>Mukesh</dc:creator>
				<category><![CDATA[Magento]]></category>
		<category><![CDATA[register]]></category>
		<category><![CDATA[registry]]></category>
		<category><![CDATA[variable]]></category>

		<guid isPermaLink="false">http://blog.chapagain.com.np/?p=591</guid>
		<description><![CDATA[Registry means registering or creating a new variable which is to be used later on in the project/code. The registry variable acts as a global variable which can be used anywhere. 
We register a variable with register() function.
We can unregister the variable with unregister() function.
To fetch the registry variable, we use registry() function.
We can store anything in the registry variable. It can be integer, string, array, etc.

In the example below, I will be showing you how to create, fetch and destroy registry variable. In other words, I mean how to ...


Related posts:<ol><li><a href='http://blog.chapagain.com.np/magento-get-store-information/' rel='bookmark' title='Permanent Link: Magento: Get store information'>Magento: Get store information</a></li>
<li><a href='http://blog.chapagain.com.np/magento-load-store-specific-product/' rel='bookmark' title='Permanent Link: Magento: Load store specific product'>Magento: Load store specific product</a></li>
<li><a href='http://blog.chapagain.com.np/magento-format-price/' rel='bookmark' title='Permanent Link: Magento: Format Price'>Magento: Format Price</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Registry means registering or creating a new variable which is to be used later on in the project/code. The registry variable acts as a global variable which can be used anywhere. </p>
<p>We register a variable with <strong>register()</strong> function.<br />
We can unregister the variable with <strong>unregister()</strong> function.<br />
To fetch the registry variable, we use <strong>registry()</strong> function.<br />
We can store anything in the registry variable. It can be integer, string, array, etc.</p>
<p><span id="more-591"></span></p>
<p>In the example below, I will be showing you how to create, fetch and destroy registry variable. In other words, I mean how to register, fetch and unregister variables in Magento. </p>
<p>Here, I will be registering store id (integer). The variable key will be &#8216;<strong>store_id</strong>&#8216;.</p>
<pre class="brush: php;">
Mage::register('store_id', Mage::app()-&gt;getStore()-&gt;getId());
</pre>
<p><strong>Mage::app()->getStore()->getId()</strong> gives the current store id.</p>
<p>The key of our newly created variable is &#8217;store_id&#8217;. To fetch the newly registered variable, we will use the following code:</p>
<pre class="brush: php;">
Mage::registry('store_id');
</pre>
<p>We will destroy/unregister the variable when we no longer need it.</p>
<pre class="brush: php;">
Mage::unregister('store_id');
</pre>
<p>Hope this helps and thanks for reading :-)</p>
<img src="http://blog.chapagain.com.np/?ak_action=api_record_view&id=591&type=feed" alt="" />

<p>Related posts:<ol><li><a href='http://blog.chapagain.com.np/magento-get-store-information/' rel='bookmark' title='Permanent Link: Magento: Get store information'>Magento: Get store information</a></li>
<li><a href='http://blog.chapagain.com.np/magento-load-store-specific-product/' rel='bookmark' title='Permanent Link: Magento: Load store specific product'>Magento: Load store specific product</a></li>
<li><a href='http://blog.chapagain.com.np/magento-format-price/' rel='bookmark' title='Permanent Link: Magento: Format Price'>Magento: Format Price</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.chapagain.com.np/magento-how-to-set-and-get-registry/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blog.chapagain.com.np/magento-how-to-set-and-get-registry/</feedburner:origLink></item>
		<item>
		<title>Magento: Read config XML nodes</title>
		<link>http://feedproxy.google.com/~r/chapagainblog/~3/6C-YiEvvFm4/</link>
		<comments>http://blog.chapagain.com.np/magento-read-config-xml-nodes/#comments</comments>
		<pubDate>Wed, 17 Feb 2010 11:08:50 +0000</pubDate>
		<dc:creator>Mukesh</dc:creator>
				<category><![CDATA[Magento]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[config]]></category>
		<category><![CDATA[node]]></category>

		<guid isPermaLink="false">http://blog.chapagain.com.np/?p=667</guid>
		<description><![CDATA[Here, I will be showing you how you can read XML nodes from config.xml file of your module. It&#8217;s through the Magento way with Mage::getConfig()->getNode() function. :)
Here is the XML code of my config.xml file. I will be reading the nodes of this XML file.


&#60;default&#62;
	&#60;catalog&#62;
		&#60;mypage&#62;
			&#60;name&#62;myname&#60;/name&#62;
			&#60;age&#62;100&#60;/age&#62;
			&#60;address_one&#62;earth&#60;/address_one&#62;
		&#60;/mypage&#62;
	&#60;/catalog&#62;
&#60;/default&#62;

Here is the code to read the node of the above XML file. Here, &#8216;catalog/mypage&#8216; is parent nodes path. It depends upon XML node layout.

// prints 'myname'
echo Mage::getConfig()-&#62;getNode('catalog/mypage')-&#62;name;

// prints '100'
echo Mage::getConfig()-&#62;getNode('catalog/mypage')-&#62;age;

// prints 'earth'
echo Mage::getConfig()-&#62;getNode('catalog/mypage')-&#62;address_one;

Hope this helps and thanks for reading.


Related posts:Magento: Read Write XML
PHP : Read ...


Related posts:<ol><li><a href='http://blog.chapagain.com.np/magento-read-write-xml/' rel='bookmark' title='Permanent Link: Magento: Read Write XML'>Magento: Read Write XML</a></li>
<li><a href='http://blog.chapagain.com.np/php-read-write-xml-with-domdocument/' rel='bookmark' title='Permanent Link: PHP : Read Write Xml with DOMDocument'>PHP : Read Write Xml with DOMDocument</a></li>
<li><a href='http://blog.chapagain.com.np/magento-access-denied-in-admin-of-custom-module/' rel='bookmark' title='Permanent Link: Magento: Access denied in admin of custom module'>Magento: Access denied in admin of custom module</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Here, I will be showing you how you can read XML nodes from <strong>config.xml</strong> file of your module. It&#8217;s through the Magento way with <strong>Mage::getConfig()->getNode()</strong> function. :)</p>
<p>Here is the XML code of my <strong>config.xml</strong> file. I will be reading the nodes of this XML file.</p>
<p><span id="more-667"></span></p>
<pre class="brush: xml;">
&lt;default&gt;
	&lt;catalog&gt;
		&lt;mypage&gt;
			&lt;name&gt;myname&lt;/name&gt;
			&lt;age&gt;100&lt;/age&gt;
			&lt;address_one&gt;earth&lt;/address_one&gt;
		&lt;/mypage&gt;
	&lt;/catalog&gt;
&lt;/default&gt;
</pre>
<p>Here is the code to read the node of the above XML file. Here, &#8216;<strong>catalog/mypage</strong>&#8216; is parent nodes path. It depends upon XML node layout.</p>
<pre class="brush: php;">
// prints 'myname'
echo Mage::getConfig()-&gt;getNode('catalog/mypage')-&gt;name;

// prints '100'
echo Mage::getConfig()-&gt;getNode('catalog/mypage')-&gt;age;

// prints 'earth'
echo Mage::getConfig()-&gt;getNode('catalog/mypage')-&gt;address_one;
</pre>
<p>Hope this helps and thanks for reading.</p>
<img src="http://blog.chapagain.com.np/?ak_action=api_record_view&id=667&type=feed" alt="" />

<p>Related posts:<ol><li><a href='http://blog.chapagain.com.np/magento-read-write-xml/' rel='bookmark' title='Permanent Link: Magento: Read Write XML'>Magento: Read Write XML</a></li>
<li><a href='http://blog.chapagain.com.np/php-read-write-xml-with-domdocument/' rel='bookmark' title='Permanent Link: PHP : Read Write Xml with DOMDocument'>PHP : Read Write Xml with DOMDocument</a></li>
<li><a href='http://blog.chapagain.com.np/magento-access-denied-in-admin-of-custom-module/' rel='bookmark' title='Permanent Link: Magento: Access denied in admin of custom module'>Magento: Access denied in admin of custom module</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.chapagain.com.np/magento-read-config-xml-nodes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blog.chapagain.com.np/magento-read-config-xml-nodes/</feedburner:origLink></item>
		<item>
		<title>Magento: Read Write XML</title>
		<link>http://feedproxy.google.com/~r/chapagainblog/~3/5GyTGK8zf_A/</link>
		<comments>http://blog.chapagain.com.np/magento-read-write-xml/#comments</comments>
		<pubDate>Wed, 17 Feb 2010 04:15:52 +0000</pubDate>
		<dc:creator>Mukesh</dc:creator>
				<category><![CDATA[Magento]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[simplexml]]></category>

		<guid isPermaLink="false">http://blog.chapagain.com.np/?p=585</guid>
		<description><![CDATA[I will be using Varien_Simplexml_Element class to read write xml nodes. The path to this class file is lib/Varien/Simplexml/Element.php
Here is a sample XML file which I am going to read through Magento code. I will also be adding an XML node to the following XML data. 


&#60;?xml version=&#34;1.0&#34;?&#62;
&#60;config&#62;
    &#60;modules&#62;
        &#60;MyNamespace_MyModule&#62;
            &#60;version&#62;0.1.0&#60;/version&#62;
        &#60;/MyNamespace_MyModule&#62;
    &#60;/modules&#62;
    &#60;frontend&#62;
   ...


Related posts:<ol><li><a href='http://blog.chapagain.com.np/magento-read-config-xml-nodes/' rel='bookmark' title='Permanent Link: Magento: Read config XML nodes'>Magento: Read config XML nodes</a></li>
<li><a href='http://blog.chapagain.com.np/php-read-write-xml-with-domdocument/' rel='bookmark' title='Permanent Link: PHP : Read Write Xml with DOMDocument'>PHP : Read Write Xml with DOMDocument</a></li>
<li><a href='http://blog.chapagain.com.np/php-read-write-xml-with-simplexml/' rel='bookmark' title='Permanent Link: PHP : Read Write Xml with SimpleXML'>PHP : Read Write Xml with SimpleXML</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>I will be using <strong>Varien_Simplexml_Element</strong> class to read write xml nodes. The path to this class file is <strong>lib/Varien/Simplexml/Element.php</strong></p>
<p>Here is a sample XML file which I am going to read through Magento code. I will also be adding an XML node to the following XML data. </p>
<p><span id="more-585"></span></p>
<pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;config&gt;
    &lt;modules&gt;
        &lt;MyNamespace_MyModule&gt;
            &lt;version&gt;0.1.0&lt;/version&gt;
        &lt;/MyNamespace_MyModule&gt;
    &lt;/modules&gt;
    &lt;frontend&gt;
        &lt;routers&gt;
            &lt;mymodule&gt;
                &lt;use&gt;standard&lt;/use&gt;
                &lt;args&gt;
                    &lt;module&gt;MyNamespace_MyModule&lt;/module&gt;
                    &lt;frontName&gt;mymodule&lt;/frontName&gt;
                &lt;/args&gt;
            &lt;/mymodule&gt;
        &lt;/routers&gt;
        &lt;layout&gt;
            &lt;updates&gt;
                &lt;mymodule&gt;
                    &lt;file&gt;mymodule.xml&lt;/file&gt;
                &lt;/mymodule&gt;
            &lt;/updates&gt;
        &lt;/layout&gt;
    &lt;/frontend&gt;
&lt;/config&gt;
</pre>
<p>Here is the Magento/PHP code to read the XML data. I have kept the XML file in the root directory of Magento installation. The XML file is named <strong>test.xml</strong>. At first, the XML file is loaded and then it&#8217;s node are read with <strong>getNode </strong>function. Then, I have printed the result.</p>
<pre class="brush: php;">
$xmlPath = Mage::getBaseDir().DS.'test.xml';
$xmlObj = new Varien_Simplexml_Config($xmlPath);
$xmlData = $xmlObj-&gt;getNode();
echo &quot;&lt;pre&gt;&quot;; print_r($xmlData); echo &quot;&lt;/pre&gt;&quot;;
</pre>
<p>You can add node with the <strong>setNode </strong>function. Here, I have set a node inside the node &#8216;modules&#8217;. The name of my new node is &#8216;mukesh&#8217; and it&#8217;s value is &#8216;chapagain&#8217;.</p>
<pre class="brush: php;">
$xmlObj-&gt;setNode('modules/mukesh','chapagain');
</pre>
<p>Hope this helps. Thanks for reading.</p>
<img src="http://blog.chapagain.com.np/?ak_action=api_record_view&id=585&type=feed" alt="" />

<p>Related posts:<ol><li><a href='http://blog.chapagain.com.np/magento-read-config-xml-nodes/' rel='bookmark' title='Permanent Link: Magento: Read config XML nodes'>Magento: Read config XML nodes</a></li>
<li><a href='http://blog.chapagain.com.np/php-read-write-xml-with-domdocument/' rel='bookmark' title='Permanent Link: PHP : Read Write Xml with DOMDocument'>PHP : Read Write Xml with DOMDocument</a></li>
<li><a href='http://blog.chapagain.com.np/php-read-write-xml-with-simplexml/' rel='bookmark' title='Permanent Link: PHP : Read Write Xml with SimpleXML'>PHP : Read Write Xml with SimpleXML</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.chapagain.com.np/magento-read-write-xml/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://blog.chapagain.com.np/magento-read-write-xml/</feedburner:origLink></item>
	</channel>
</rss>
