<?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>Jefim Borissov &#187; modx</title>
	<atom:link href="http://jefim.eu/blog/tag/modx/feed/" rel="self" type="application/rss+xml" />
	<link>http://jefim.eu/blog</link>
	<description>Житие мое</description>
	<lastBuildDate>Fri, 05 Aug 2011 22:28:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.3</generator>
		<item>
		<title>ORM for PHP &#8211; Doctrine</title>
		<link>http://jefim.eu/blog/2009/06/orm-for-php-doctrine/</link>
		<comments>http://jefim.eu/blog/2009/06/orm-for-php-doctrine/#comments</comments>
		<pubDate>Thu, 11 Jun 2009 16:29:09 +0000</pubDate>
		<dc:creator>Jefim</dc:creator>
				<category><![CDATA[Assorted]]></category>
		<category><![CDATA[cms]]></category>
		<category><![CDATA[modx]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://jefim.eu/blog/?p=49</guid>
		<description><![CDATA[I have been always dreaming about some magical component for PHP developers that would free us from the pain of handling databses. And I have mostly seen useless wrappers for native database functions of PHP. Those always tried to claim that the will make it all better. No luck. Until recently (well, a bit more [...]]]></description>
			<content:encoded><![CDATA[<p>I have been always dreaming about some magical component for PHP developers that would free us from the pain of handling databses. And I have mostly seen useless wrappers for native database functions of PHP. Those always tried to claim that the will make it all better. No luck. Until recently (well, a bit more than recently) I looked into a thing called <a id="ekxb" title="ORM (Object-relational mapping)" href="http://en.wikipedia.org/wiki/Object-relational_mapping">ORM (Object-relational mapping)</a>. Specifically - an ORM for PHP called <a id="dqp9" title="Doctrine" href="http://www.doctrine-project.org/">Doctrine</a>.<span id="more-49"></span></p>
<p>Now, having some experience in trying to do database handling manually (e.g. having to use <em>mysql_connect</em> etc all the time) and letting Doctrine to do this for you I have one phrase to tell you: <strong>if you are not using ORM already you are losing a lot of precious time</strong>.</p>
<p>So, just as a small example of ORM godlyness. Really small and really simple. We need to create a page which holds orders from clients. Each order consists of items (duh!). This means two database entities - Orders and Items</p>
<p>First, let us see what we would need to do if we did not use Doctrine (or some another ORM):</p>
<ul>
<li>Create an SQL script for table creation (the main problem here is that SQL scripts are unreadable at all):
<ul>
<li><em>CREATE TABLE 'order' (id INT NOT NULL AUTO_INCREMENT, client_name VARCHAR(255), client_address VARCHAR(255));</em></li>
<li><em>CREATE TABLE 'item' (id INT NOT NULL AUTO_INCREMENT, title VARCHAR(255), cost FLOAT, order_id INT NOT NULL);</em></li>
</ul>
</li>
<li>Create classes Order and Item. This is always very annoying for one reason - you have to rewrite CRUD functions over and over and over and over again. I hate it. I am not going to write the CRUD support for those classes right now, but if you did it once - you do not want to do it again.</li>
</ul>
<p>Well, that was pretty simple, but 1) time-consuming; 2) cofusing (you cannot see the overall scheme of things; 3) it is Boring.</p>
<p>Let's take a look how you can do this whole thing with Doctrine in no time. The basic idea is to create a YAML (*.yml) file, which describes your database scheme. Here is how our case would look like:</p>
<pre><strong><span style="color: #0000ff;">      Order:
        columns:
          client_name: string(255)
          client_address: string(255)
      Item:
        columns:
          title: string(255)
          cost: float
          order_id: integer
        relations:
          Order:
            local: order_id
            foreign: id
            foreignAlias: items</span></strong></pre>
<p>Voila. This is it. After that the only thing you have to do is type "php doctrine build-all-reload" in your favourite console and let Doctrine create the tables in the database and the classes for you. Right after that you can start using those to implement your business logic without caring about the CRUD functions!</p>
<p>In my script I could go like this right away:</p>
<pre><strong><span style="color: #0000ff;"><span style="color: #808080;">      // Create an order and set its vars
<span style="color: #0000ff;">      $order = new Order();
      $order-&gt;client_name = "Vasili Pupkin";
      $order-&gt;client_address = "Bobrujsk";</span>
      // Add a new item
<span style="color: #0000ff;">      $order[0]-&gt;title = "Saaremaa Vodka 80";
      $order[0]-&gt;cost = 15;</span>
      // Add another item (which plays very well with the first item)
<span style="color: #0000ff;">      $order[1]-&gt;title = "Good pickles";
      $order[1]-&gt;cost = 2;</span>
      // Save the order to the database
<span style="color: #0000ff;">      $order-&gt;save();</span></span></span></strong></pre>
<p>And that is the end of that story. Create a YAML file and start implementing the business-logic instead of spending a couple of hours (or more) writing boring monkey-oriented code.</p>
]]></content:encoded>
			<wfw:commentRss>http://jefim.eu/blog/2009/06/orm-for-php-doctrine/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>A bit of MODx CMS criticism</title>
		<link>http://jefim.eu/blog/2009/05/a-bit-of-modx-cms-criticism/</link>
		<comments>http://jefim.eu/blog/2009/05/a-bit-of-modx-cms-criticism/#comments</comments>
		<pubDate>Fri, 29 May 2009 16:48:50 +0000</pubDate>
		<dc:creator>Jefim</dc:creator>
				<category><![CDATA[Assorted]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[cms]]></category>
		<category><![CDATA[modx]]></category>

		<guid isPermaLink="false">http://jefim.eu/blog/?p=41</guid>
		<description><![CDATA[Today I am going to talk about MODx CMS again. Now, the first post on this topic covered my first impressions of this product. And now I have something else to say. This time I am going to go a bit deeper into minuses of MODx. Why? Well, all the pluses are available on the [...]]]></description>
			<content:encoded><![CDATA[<p>Today I am going to talk about MODx CMS again. Now, the first post on this topic covered my first impressions of this product. And now I have something else to say.</p>
<p>This time I am going to go a bit deeper into minuses of MODx. Why? Well, all the pluses are available on the official website and I do not see the reason for repeating those. This post does not in anyway mean that MODx is a bad product! It just has some bad sides that I would find very useful to read about before starting to build a website based on this system. This post is healthy citicism and maybe a precaution for those wondering what can't you do with MODx.<span id="more-41"></span></p>
<h2>1. Documentation</h2>
<p>One of the most important minuses I have noted about MODx and anything related to documentation. Well, it is horrible. That concernes practically eveything. MODx heavily relies on customization by adding such things as chunks, snippets, plugins and modules. Not only the documentation of the MODx core system is horrible (and can be shown as agood example of how to not write documentation) but this practice also concerns anything starting from snippet usage to writing your own MODx components.</p>
<p>Now, I undertand that MODx did not even hit version 1.0 yet, but this (boring) part of any project is crucial to its success as the will to start using any framework-like product mostly depends on the features offered (50%) and documentation (50%). This is obvious and I do not understand why the MODx team is not concerned about this.</p>
<p>In the end I found myself googling such things as "wayfinder placeholders" and "ditto parameters" every now and then, since I keep forgetting those details. In addition to that all the documentation is done in different formats and designs, which is very annoying.</p>
<p>As a solution it would be not so hard to make some kind of a public documentation repository available to the MODx contributors with unified rules about documenting their code. Some kind of MSDN for MODx (not that complex of course).</p>
<p>Or as for now (e.g. until the 1.0 release) there should be at least a unified refence on all bundled MODx components!</p>
<h2>2. Administrating area (manager) customization</h2>
<p>At the moment the admin zone of MODx is pretty much monolithic. It cannot be changed fundamentally. And this is a major drawback, since admin zone is a vast part of the website itself. You cannot hide all of the stuff here and then, you cannot make it look too user-friendly after all (yes, I know about roles, groups etc. - it is far from ideal). Adding new custom functionality to the admin area can be done through modules, though the only place you can actually add this functionality is to the "Modules" menu (I get the logic, but I do not get why is there such a limit?).</p>
<p>The admin area must be fully customizable. Every single piece of it. Without editing the core MODx files.</p>
<p>* Many MODx people can, of course, say that there is MODx Revolution (which looks very promising), but at this point I will not discuss anything connected to it as the latest alpha was very buggy (right from the start) and unusable.</p>
<h2>3. Templating engine</h2>
<p>As already said in the previous post about MODx, the templating engine is quite far from being perfect. It has most of the necessary features, but far from Smarty by its functionality. I, personally, lack logical constucts ({if}). BUT! The behaviour of the templating engine can be changed. You can hook into the output event and modify the output as you wish (e.g. implementing as {if} would be quite easy, in fact, I have done it already as I cannot live without it and I do ot know how people use MODx without it - this simple plugin will be available as soon as I have time to make it look pretty).</p>
<p>Again, there is NO way you can mimic Smarty {if} with snippets - they simply work on a different level of MODx.</p>
<h2>Conclusion</h2>
<p>To conclude... Well, MODx is still pretty solid CMS system, which offeres a lot of features and works as a charm if configured and used corectly. Its disadvantage in the documentation area is, obviously, an effect of its open-source nature. The templating engine problems can be solved by creating a plugin (although it is quite strange to me that Smarty-like features are not present in MODx). Therefore, the only major problem at the moment is the manager customization. This problem is promised to be fixed when Revolution hits the ground but from what I've seen in the latest alpha it won't be a reliable product in near future. Therefore - modules are the only way to affect the admin area without going inside the core files of MODx.</p>
]]></content:encoded>
			<wfw:commentRss>http://jefim.eu/blog/2009/05/a-bit-of-modx-cms-criticism/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>MODx CMS overview</title>
		<link>http://jefim.eu/blog/2009/05/modx-cms-overview/</link>
		<comments>http://jefim.eu/blog/2009/05/modx-cms-overview/#comments</comments>
		<pubDate>Tue, 12 May 2009 08:59:14 +0000</pubDate>
		<dc:creator>Jefim</dc:creator>
				<category><![CDATA[Assorted]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[cms]]></category>
		<category><![CDATA[modx]]></category>

		<guid isPermaLink="false">http://jefim.eu/blog/?p=11</guid>
		<description><![CDATA[Some MODx related post discussing MODx cons is also here. 0. Intro Today I am going to say something about MODx CMS. At the moment I have used it to make one website as well as I am using it right now to make another. This is mainly the suggestion of the client, so I [...]]]></description>
			<content:encoded><![CDATA[<p>Some MODx related post discussing MODx cons is also <a href="http://jefim.eu/blog/2009/05/a-bit-of-modx-cms-criticism/" target="_blank">here</a>.</p>
<h3>0. Intro</h3>
<p>Today I am going to say something about <a href="http://www.modxcms.com" target="_blank">MODx CMS</a>.</p>
<p>At the moment I have used it to make one website as well as I am using it right now to make another. This is mainly the suggestion of the client, so I am using it not because I like it so very much, but just because of circumstances.</p>
<p>So far my experience with it is, actually, quite pleasant. MODx CMS has a lot of fine features. At the moment I can tell that it at least has the minimal things that are required to make a website. So far I have understood, that most of the MODx functionality relies on the following things: templates, template variables (TV), chunks and snippets. All the other things are quite auxiliary.<br />
So, let us take a look and see what those are. <span id="more-11"></span></p>
<h3>1. Templates</h3>
<p>Templates are templates. I think that any PHP programmer should be familiar with the idea of those. OK. So what about the MODx templates? Well, I must say - MODx templates are not the best out there. And probably anybody who used Smarty (I am a fan <img src='http://jefim.eu/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  ) will feel the same about the MODx templates. Imagine a situation - there is a template variable - URL of an image you want to show. Obviously your template code is something like this:</p>
<pre>&lt;img alt="MyTemplateImage" src="[*image_url*]" /&gt;</pre>
<p>Very simple, huh? But what if the user leaves this variable empty? Then you will get the following code:</p>
<pre>&lt;img alt="MyTemplateImage" src="" /&gt;</pre>
<p>Which is horrible! Absolutely horrible. This leaves two options:</p>
<ol>
<li>Make the user input the whole &lt;img ... /&gt; code.  Though this is unacceptable, since most of the client I met do not have any idea that there is "markup" in the world.</li>
<li>Do not show the image at all <img src='http://jefim.eu/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </li>
</ol>
<p>So, basically what I am trying to say is - there are <strong>no logical operators in templates <span style="text-decoration: underline;">by default</span></strong>! Yes, <span style="text-decoration: underline;"><strong>by default</strong></span>. There is a add-on called <a href="http://wiki.modxcms.com/index.php/PHx#Introduction" target="_blank"><strong>PHx</strong> (Placeholders Xtended)</a>, which makes this thing possible, though the syntax is horrible (I guess due to the MODx template syntax). Take a look at the solution of our problem:</p>
<pre>[+phx:if=`[*image_url*]`:is=``:then=``:else=`&lt;img alt="MyTemplateImage" src="[*image_url*]" /&gt;`+]</pre>
<p>And of course, just as a comparison, the beauty of Smarty:</p>
<pre>{if $image_url neq ""}
&lt;img alt="MyTemplateImage" src="[*image_url*]" /&gt;
{/if}</pre>
<p>This is what makes the difference. In MODx+PHx I would have to use a workaround to solve this. And if I have a larger chunk of code - I would have to separate it into a chunk.<br />
Now, you might have the impression that I hate MODx. That is not true. At the moment I am trying to point out some of the bad sides I found.</p>
<h3>2. Tamplate variables</h3>
<p>Template variables (TV) are custom variables you want user to be able to insert into the page template. E.g. the [*image_url*] in the previous part was referring to a TV. You can create a new TV in the manager area of MODx and then assign which templates have access to that variable. Right after that any page using one of those templates will have an additional field below the content editor, where the user can change the TV content. In our case with [*image_url*] we would want to set it's type to <em>Image</em> and the user will have the opportunity to upload an image or enter a URL of an existing image. The image TV will also have a nice preview. A nice way to help simple customers adjust the appearance and/or the content of the website.</p>
<h3>3. Chunks</h3>
<p>Now it is time to talk about chunks. What are they? They are simply chunks of HTML code that make the templates look neat and clean. E.g. usually in a page you would have a header, a sidebar, content space and a footer. So this is what chunks are made for (basically) - you put those parts into separate chunks and then your template itself looks like this:</p>
<pre>{header_chunk}
{sidebar_chunk}
&lt;div id="content"&gt;[*content*]&lt;/div&gt;
{footer_chunk}</pre>
<p>So this is a matter of neatness and separation of different page areas. Besides that - chunk are small templates themselves. This means that you can use other chunks within them, you can use variables and snippets. I like the idea and implementation of these.</p>
<h3>4. Snippets</h3>
<p>Snippets are like chunks. Except that they are mostly used with PHP code. E.g. if you your website to show current date - you will not use a chunk, since it must not contain any code. You would create a snippet, which returns the date. There are a couple of snippets that are really useful that come in the default package of MODx. Such as Wayfinder (can generate a menu for example), Ditto and Breadcrumbs. And, I actually do not know what else can I say about them <img src='http://jefim.eu/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h3>5. Conclusion</h3>
<p>In the end. I want to say that the overall feeling about the whole MODx CMS was pretty Ok. It has everything to be a nice CMS for a website. Quite an easy installation procedure, some fine-tuning capabilities, templates and so on. I would definitely advise you to at least try it out and decide for yourself if you want to use it or not.</p>
<p>I would say that MODx CMS is almost ideal for small corporate websites. For larger projects it would require more tuning and messing with add-ons (e.g. PHx). It can also be a pretty good blog engine (I tried it out, but requires a lot of tuning if you want a feature-rich blog), though I would definitely use a dedicated blog product like WP for blogs (and as you can see I am using WP) .</p>
<p>Thanks for your attention. Post comment if you have any.</p>
]]></content:encoded>
			<wfw:commentRss>http://jefim.eu/blog/2009/05/modx-cms-overview/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

