<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	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/"
	>

<channel>
	<title>ActiveCodeline &#187; template</title>
	<atom:link href="http://activecodeline.com/tag/template/feed" rel="self" type="application/rss+xml" />
	<link>http://activecodeline.com</link>
	<description>Blog site of Branko Ajzele, web application developer.</description>
	<lastBuildDate>Tue, 07 Sep 2010 05:59:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Magento plus some CMS, simple and quick integration tip</title>
		<link>http://activecodeline.com/magento-plus-some-cms-simple-and-quick-integration-tip</link>
		<comments>http://activecodeline.com/magento-plus-some-cms-simple-and-quick-integration-tip#comments</comments>
		<pubDate>Tue, 03 Nov 2009 13:35:35 +0000</pubDate>
		<dc:creator>branko</dc:creator>
				<category><![CDATA[Magento]]></category>
		<category><![CDATA[template]]></category>

		<guid isPermaLink="false">http://activecodeline.com/?p=929</guid>
		<description><![CDATA[Sometimes due loosely, undefined, agreement around some feature and deadline that&#8217;s thrown upon us, developers need to look for the fastest solution around some requirement. Fastest but stable is the key word here. Here is a practical example of one can easily connect Magento with some other system. In my case I had Magento plus [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes due loosely, undefined, agreement around some feature and deadline that&#8217;s thrown upon us, developers need to look for the fastest solution around some requirement. Fastest but stable is the key word here.<span id="more-929"></span></p>
<p>Here is a practical example of one can easily connect Magento with some other system. In my case I had Magento plus WordPress integration in which I needed to pull some user data, such as latest users, from WordPress into Magento block.</p>
<p>Stuff like these can easily be done in two easy steps</p>
<ul>
<li>Create custom Magento controller. <a href="http://activecodeline.com/magento-custom-email-contact-form-with-notification-system">This article</a> shows you how you can create custom controller.</li>
<li>Use built in PHP function <strong>file_get_contents</strong> and pass it a full link to controller action that will return html string for given block. Using function like $htmlContent = @file_get_contents($someUrl); if($htmlContent) { echo $htmlContent; }  will give you some error proof behaviour. Simple but useful for quick stuff.</li>
</ul>
<p>That&#8217;s it. Later once you get on the milestone track you can easily convert these to AJAX calls.</p>
]]></content:encoded>
			<wfw:commentRss>http://activecodeline.com/magento-plus-some-cms-simple-and-quick-integration-tip/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress single post templates withouth any plugin needed</title>
		<link>http://activecodeline.com/wordpress-single-post-templates-withouth-any-plugin-needed</link>
		<comments>http://activecodeline.com/wordpress-single-post-templates-withouth-any-plugin-needed#comments</comments>
		<pubDate>Sun, 16 Nov 2008 19:41:29 +0000</pubDate>
		<dc:creator>branko</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[template]]></category>

		<guid isPermaLink="false">http://activecodeline.com/?p=334</guid>
		<description><![CDATA[Until few days ago I was blabbering around with my friends how I dislike the WordPress due to lack of object oriented programming features and so on. This weekend I revised my thoughts and come to conclusion, once again, how WordPress is great. Sometimes OOP is not the best way to go. And truth be [...]]]></description>
			<content:encoded><![CDATA[<p>Until few days ago I was blabbering around with my friends how I dislike the WordPress due to lack of object oriented programming features and so on. This weekend I revised my thoughts and come to conclusion, once again, how WordPress is great. Sometimes OOP is not the best way to go. And truth be told, OOP CMS solution&#8217;s are sometimes far more slower. This weekend I got a whole new look at WordPress and the way of using it. I&#8217;ll be working on a project, a community site for my friend and decided to go with WordPress.<span id="more-334"></span></p>
<p>This will not be the regular WordPress posts and pages. I plan to implement a whole new philosophy into it. I&#8217;ll be using an outside /mylibrary folder with full object oriented classes and methods representing models which I&#8217;ll be working on. I wrote few lines of code inside the index.php file in the root of WordPress folder to autoload all of my classes and stuff from /mylibrary when needed to avoid include&#8217;s ore require&#8217;s inside each of my template files.</p>
<p>Most of the stuff inside /mylibrary will call the default built in WordPress functions for manipulating posts and pages, therefore most of /mylibrary stuff will work only inside theLoop of the WordPress template (for now). My idea is to use the Custom Fields functionality, introduced in the newer versions of WordPress, extensively. My idea is to have a special category, let&#8217;s say, &#8220;user&#8221; and a post assigned to each user like &#8220;first-lastname&#8221; then the page generated by the url &#8220;http://somesite.domain/user/first-lastname&#8221; with the basic post data plus the custom field data.</p>
<p>All of this data assigned to the &#8220;user&#8221; post inside the &#8220;/user&#8221; category will be done transparently to the user. I already made a class that automatically creates a post with basic post daa like title. content, excerpt plus data like tags and custom fields. All I need to do now is to create a page with some form on it and tie my form submit action to execute that class and method I created passing it all the necesery data. This may sound like a lot of work, or even complicated, but hey&#8230; few weeks with  Magento and WordPress becomes a toy <img src='http://activecodeline.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Anyhow&#8230; there are still few things I&#8217;m looking around to get the full picture and power of WordPress. One of them is Single post custom template. If you open admin interface in WordPress and go to Edit &gt; Page you can see that you can assign a template foreach page if you like. So my question is, why can&#8217;t you do it for Single post? Well, you can, just keep on reading <img src='http://activecodeline.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>My idea is to create directory /layouts inside the root of my custom theme. Inside directory /layouts I created two additional folders named /category and /post. Inside directory /category I would like to have special template file foreach of my categories. If my url is like</p>
<p>http://somename.domain/categoryname/postname</p>
<p>then opening http://somename.domain/categoryname/ would open the category template, which by default is archive.php file and I want it to open the /layouts/category/categoryname.php file.</p>
<p>If I were to open the</p>
<p>http://somename.domain/categoryname/postname</p>
<p>I would be directed to single.php file by default and I want it to be pointing to /layouts/post/categoryname.php template file.</p>
<p>So how do I get the defaults to do what I mentioned previously.</p>
<p>All you need to do is to open the functions.php file and place the following code in it. I placed it at the very top of the functions.php file.</p>
<p><em>&lt;?php</p>
<p>/**<br />
* Loads the single post template<br />
* I have set the /layouts subfolder as the folder to store some custom layouts<br />
* Study the function body&#8230; this function ca be reused to fully manage layouts<br />
* in various scenarios<br />
*<br />
* Currently function is written to load the /layouts/post/catName.php file<br />
* instead of the single.php file. So if you created the category &#8220;stuff&#8221;<br />
* and added few templates to it, then when you open the post for that category<br />
* this function fill try to load the post in yourtheme/layouts/post/stuff.php file<br />
*<br />
* @author Branko Ajzele<br />
*/<br />
add_filter(&#8216;single_template&#8217;, create_function(&#8216;$t&#8217;, &#8216;foreach( (array) get_the_category() as $cat ) { if ( file_exists(TEMPLATEPATH . &#8220;/layouts/post/&#8221;.$cat-&gt;name.&#8221;.php&#8221;)) return TEMPLATEPATH . &#8220;/layouts/post/&#8221;.$cat-&gt;name.&#8221;.php&#8221;; } return $t;&#8217; ));</p>
<p>/*</p>
<p>in the statement<br />
foreach( (array) get_the_category() as $cat )</p>
<p>$cat is a object of type stdClass as below</p>
<p>stdClass Object<br />
(<br />
[term_id] =&gt; 4<br />
[name] =&gt; duznosnik<br />
[slug] =&gt; duznosnik<br />
[term_group] =&gt; 0<br />
[term_taxonomy_id] =&gt; 4<br />
[taxonomy] =&gt; category<br />
[description] =&gt;<br />
[parent] =&gt; 0<br />
[count] =&gt; 3<br />
[object_id] =&gt; 16<br />
[cat_ID] =&gt; 4<br />
[category_count] =&gt; 3<br />
[category_description] =&gt;<br />
[cat_name] =&gt; duznosnik<br />
[category_nicename] =&gt; duznosnik<br />
[category_parent] =&gt; 0<br />
)</p>
<p>*/</p>
<p>add_filter(&#8216;category_template&#8217;, create_function(&#8216;$t&#8217;, &#8216;foreach( (array) get_the_category() as $cat ) { if ( file_exists(TEMPLATEPATH . &#8220;/layouts/category/&#8221;.$cat-&gt;name.&#8221;.php&#8221;)) return TEMPLATEPATH . &#8220;/layouts/category/&#8221;.$cat-&gt;name.&#8221;.php&#8221;; } return $t;&#8217; ));</p>
<p>?&gt;</em></p>
<p>Hope some of you find this useful. You can play around with the add_filter function to make more complex layout routes, just be careful not to get lost <img src='http://activecodeline.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://activecodeline.com/wordpress-single-post-templates-withouth-any-plugin-needed/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Broken Compare Products popup page after Magento upgrade</title>
		<link>http://activecodeline.com/broken-compare-products-popup-page-after-magento-upgrade</link>
		<comments>http://activecodeline.com/broken-compare-products-popup-page-after-magento-upgrade#comments</comments>
		<pubDate>Tue, 12 Aug 2008 18:30:57 +0000</pubDate>
		<dc:creator>branko</dc:creator>
				<category><![CDATA[Magento]]></category>
		<category><![CDATA[template]]></category>

		<guid isPermaLink="false">http://activecodeline.com/?p=108</guid>
		<description><![CDATA[Recently I did an upgrade of Magento 1.0.19870.1 to Magento 1.1.2 version. Most of the things went pretty smooth, without any errors. However, if you&#8217;re using custom theme instead of the built in you&#8217;re probably run into some errors. One of those errors will most probably be broken page. Among few other problems, I had [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I did an upgrade of Magento 1.0.19870.1 to Magento 1.1.2 version. Most of the things went pretty smooth, without any errors. However, if you&#8217;re using custom theme instead of the built in you&#8217;re probably run into some errors. One of those errors will most probably be broken page.</p>
<p>Among few other problems, I had a broken popup page on Compare Products. If you login to backend interface and turn on show hint&#8217;s for template, you can easily see from where each part of the page is pooled from. Compare Products is pooled from &#8220;app/design/frontend/default/default/template/catalog/product/compare/&#8221;. There you can see two files: &#8220;sidebar.phtml&#8221; and &#8220;list.phtml&#8221;. The other one is the one that is actually popup. Since my popup error was specific: it opened, but showed none of the compare info, it was logical to have a look inside &#8220;list.phtml&#8221; file. <span id="more-108"></span></p>
<p>What I don&#8217;t get it, is why do Magento boys and girls did not use the same helper functions they used in Magento version 1.0.19870.1. My Compare Products popup page get broken because it was calling non existent function. Check the following code.</p>
<p>From version 1.0.19870.1</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">helper</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'review/product'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getSummaryHtml</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_item</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'short'</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">helper</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'catalog/product'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getPriceHtml</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_item</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>From version 1.1.2</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getReviewsSummaryHtml</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_item</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'short'</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getPriceHtml</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_item</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>It&#8217;s obvious the function names have change, therefore it&#8217;s obvious why template page broke. When dealing with these kind of problems, my approach is to first enable template hints in admin backend, then open the template file where page brakes. If you&#8217;re using custom made template, problems will probably be template related.</p>
]]></content:encoded>
			<wfw:commentRss>http://activecodeline.com/broken-compare-products-popup-page-after-magento-upgrade/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Magento upgrade and broken templates</title>
		<link>http://activecodeline.com/magento-upgrade-and-broken-templates</link>
		<comments>http://activecodeline.com/magento-upgrade-and-broken-templates#comments</comments>
		<pubDate>Sat, 02 Aug 2008 19:16:29 +0000</pubDate>
		<dc:creator>branko</dc:creator>
				<category><![CDATA[Magento]]></category>
		<category><![CDATA[template]]></category>
		<category><![CDATA[upgrade]]></category>

		<guid isPermaLink="false">http://activecodeline.com/?p=56</guid>
		<description><![CDATA[Few days ago I had a task of upgrading Magento ver. 1.0.19870.1 to Magento ver. 1.1.1. When you are doing something like that on your own development machine, you probably don&#8217;t care much about backing up your database and installation folder. On my development machine I had a clean install of version 1.0.19870.1 where I [...]]]></description>
			<content:encoded><![CDATA[<p>Few days ago I had a task of upgrading Magento ver. 1.0.19870.1 to Magento ver. 1.1.1. When you are doing something like that on your own development machine, you probably don&#8217;t care much about backing up your database and installation folder. On my development machine I had a clean install of version 1.0.19870.1 where I merely entered few products, categories and other minor things. I had no other theme besides custom one. Before I was ready to do a update to real, shared, remote development machine I decided to test the update on my machine. </p>
<p>Performing local update went smoothly as it gets. On my surprise, everything work as it should be. I was convinced I can go and make upgrade to remote development machine. I had no SVN setup to my remote machine so all my code transfer was done trough FTP. Basically if you&#8217;re performing your upgrade trough full archive file all you need to do is copy content from archive to your root Magento installation and overwrite everything you&#8217;re asked to overwrite. Sound&#8217;s easy, doesn&#8217;t it? Well it is easy and your upgrade should go clean and without any glitch, that is if you are using built in theme. If you&#8217;re using a custom made theme, chances are you&#8217;re rune into trouble like i did.<span id="more-56"></span></p>
<p>Magento is a very modular system. If you do a little check on default archive for Magento version 1.1.2 (latest, as of time of this writing) you will see it contains 6 383 files across 2 171 folders. This is huge number of files if you ask me. Magento&#8217;s philosophy for <a href="http://www.magentocommerce.com/design_guide/articles/how-magento-builds-content">building themes</a> is somewhat complex. When i say complex i don&#8217;t think in terms on hard to learn but in terms of everything is co cut up into meaningful peaces as they say. However, number of this meaningful peaces is huge. This alone is not the problem, although will take some time getting around. Problem is in the PHP code inside those meaningful little peaces.</p>
<p>Let me be specific. If you want to change something in your checkout page, let&#8217;s say make it different then it is in the default template then you go and create your theme according to the <a href="http://www.magentocommerce.com/design_guide">manual</a>. Then you realize, that if you want to change checkout page you need to change app/design/frontend/default/your_theme/template/checkout/cart.phtml to suite your needs. You do stuff like calling some Magento helper functions, modifying HTML, adding all sort of styles and so on. Magento works by first looking for files within &#8220;your_theme&#8221; folder. If corresponding file is there it will pick it up, if not it will use it&#8217;s own from the default theme. This is very modular if you ask me. However, there is one problem to it. What if someone deleted some helper or some other function you used inside your theme file? Well you would get errors and your online Magento powered shop would fail to work.</p>
<p>When you do upgrade you overwrite files from default theme folder. However, you preserve all the old files inside your custom theme folder. These are the files that worked with Magento version before the upgrade. In order for them to work after the upgrade all the functions called from this template should be existing. I&#8217;ve read a response comment on Magento forum where some said &#8220;templates for *** have changed significantly&#8221;, probably meaning something like &#8220;you&#8217;ll have to change your theme significantly because of it&#8221;.</p>
<p>I&#8217;m not here to judge Magento because of this. It&#8217;s a great product, it&#8217;s free, it has very bright future and so on. I&#8217;m just trying to lay out my conclusions. I was pretty surprised when my Magento shop broke after upgrade, when some things started disappearing and so on. On the other hand, it was quite good experience from which I learned a thing or two about Magento. And one advice before and after the upgrade; try to switch your site to default theme and first do a full check to see if everything is working here. If it is, then you&#8217;re ready to bug hunt your theme.</p>
]]></content:encoded>
			<wfw:commentRss>http://activecodeline.com/magento-upgrade-and-broken-templates/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
