Model-View-Controller (MVC) architecture for CodeCharge developers
CodeCharge Studio is a nice web-development RAD tool. But it offers a rather specific code, which is more of web 1.0 code. What I want to tell is that code architecture of modern frameworks (CodeIgniter, Zend, CakePHP etc) and code generated by CodeCharge Studio - are very different.
That difference could make the process of integration of frameworks and CCS a bit complex. Additionally, understanding of frameworks can be complicated by getting used to CCS code/object model, which indeed happened to me after using CCS over 7 years.
To somewhat alliviate this process, I decided to make a sketchy mapping between PHP frameworks and CCS. I assume you can do hello world application both in CodeCharge Studio and in some framework. At least, reading some MVC tutorual would be really helpful to understand further analogies.
Concept 1) CodeCharge Studio "Page"
CCS page is a place, a container where you can add various forms. This place is visual and you don't look at the code behind page too often. When developing "Page" in some PHP framework, you're working in code editor with Page class called "Controller"
CCS page contains forms vs. Controller class contains Action methods.
Concept 2) CCS Grid Forms.
In CodeCharge Studio Grid is a well-defined component. But in MVC-based PHP frameworks there is no such a conception as Grid. Grid is something you create each time with code manually. Framework Grid typically is separated bewteen two layers : in Controller action method your custom code fetches data for grid and assignes to View variable. This makes you responsible for further adding this variable into .phtml template that will typically iterate throgh this variable via foreach loop. E.g.
//MyController.php file
class Controller {//responsible for original page display
function index() {
$this->view->data = $model->getData(); //fetches data from model
}}
//MyView.phtml file
<h1>Header</h>
<?foreach ($this->data as $item) print "Item=$item";
?>
Concept3 - CCS Record Forms
In CodeCharge Studio forms are automaticallygenerated and automatically process Insert/Update/Delete. In MVC frameworks things are a bit low level, which allows developers to have more control over this process. While index() method in Controller (Page) is typically reponsible for displaying "Page", other controller methods that we implement will contain code that checks which form button is pressed and runs corresponding SQL code or object call to perform DB update.
In other words, methods in Controller class are called actions for a reason.
Here is a sample action code:
class Controller {function index() {......}
function deleteItem () {
if ($this->request->GetParam("Delete"))
$this->model->delete_user_action();}
}
Form display: in MVC form display can be implemented various ways, often with raw html in view template files, but e.g. in Zend Framework you can use Form class which is very well-designed and supports a lot of various Decorators.
Concept 4 - Events.
Naturally, you can add you custom code in any part of controller which kind of similar to Events in CCS, but far more flexible. In the example above you may add code into the beginning of deleteItem() function, into the end or any other place.
In MVC events are where you want them to be.
As to Page events (Before Show, After Initialize etc.), they can be replaced by custom code inside constructor class of your controller, because iit's initialized each time page is accessed (in CCS you'd have to insert code into Common.php file).
Any MVC application is typically launched from index.php boostrap file, which then loads responsible Controller class. Before this class is loaded, you may insert code that is launched no matter which page or controller is accessed.
I hope this introductory comparison has made MVC frameworks more clear for CCS developers. If you have any comments, suggestions, offers - I'd be glad to hear from you.
And a helping table in the end:
| CodeCharge Studio | PHP Frameworks |
| Page | Controller class, index() method |
| Grid form | index() method, template file |
| Record form | actions methods in Controller class |
| Events | Custom code in index or action methods in arbitratry places |
Regards,
Alex
Why invest into Drupal?
In my real-life experience, there have been cases where selection of Open Source technologies versus technologies of big closed source players was a tough choice, but eventually helped companies save thousands of dollars.
This is just a general consideration. But this is not the end of the story, since there are plenty of open source tecnhologies, frameworks, cms systems to choose from. If you had a chance to make another, even more refined choice, what would it be?
According to recent Gartner research this open source technology is ... Drupal!
And I agree it's not just a choice, there is a strong combination of factors that all-together point at Drupal.
Experts say that Drupal is not just another niche player in social software quadrant (see this social software research). By several Garner experts Drupal has been recognized as visionary in it's own field. In my opinion this is Drupal's flexibility that allows it to extend in various fields of software development, where other rivals can't grow. Particularly, in the old argument of CMS vs. frameworks Drupals stays a universal solutions, a true content-management framework (CMF).
That's why in many cases, not just as Drupal developer, but more as a web developer I prefer to stick to Drupal when considering n options for customer's web site.
Protecting Mosets Tree catalog with ajax-based Captcha
One of the most popular Joomla components is a catalog components called Mosets Tree. But to keep this catalog open for anonymous posters, providing quick access, one often needs to protect "Add Listing" page.
Unfortunately, Mosets Tree component doesn't provide captcha.
But protecting catealog from spam submissions is still a doable task.
Let me outline how this can be done.
Please be aware that this article requires some knowledge of PHP and JQuery coding.
Drupal: user-friendly SEF links in Tagadelic module
Drupal users often compain that Tagadelic module, while displaying nice tags clouds, still provides direct links to tag categories which contain tags numbers, not tag names. This is not terribly good for search engine optimization. So I created a solution for such a case, all you need to do is to replace this function in modules/tagadelic/tagadelic.module :
function theme_tagadelic_weighted($terms) {
$output = '';foreach ($terms as $term) {
$link = taxonomy_term_path($term);
if (module_exists('pathauto')) {
$alias_data = _pathauto_existing_alias_data($link);
$new_link = $alias_data['old_alias'];
if ($new_link) $link = $new_link;}
$output .= l($term->name, $link, array('attributes' => array('class' => "tagadelic level$term->weight", 'rel' => 'tag'))) ." \n";
}
return $output;
}
Search functionality in Drupal
If you want to enable search functionality in Drupal somewhat beyond Search module, here are basic options that you will most likely arrive at. I hope they will make the picture of how to implement search in Drupal more clear for you:
- Faceted Search module. This is something between basic search and advanced search. It
provides a search API and a search interface for allowing users to browse content in such a way that they can rapidly get acquainted with the scope and nature of the content, and never feel lost in the data. More than a search interface, this is an information navigation and discovery tool.
Disadvantage: this is a data-base heavy module, requires better hosting or database optimization - ApacheSolr - a real solution for high-traffic sites, lots of search features basic on famous Lucene engine. This is a module that integrates Solr into Drupal - http://drupal.org/project/apachesolr
Disadvantage: requires dedicated hosting - Simple custom Drupal search form:
Sometimes all you need is a couple more features to your search, then most likely all you need to do is to build a simple search form using Drupal Forms API and use it in conjunction with filters in Views module, which displays filtered data on your Drupal page.
Disadvantage: you get only functionality that you build, no extras
Master Drupal faster with Drupal-Builder
I am developing an interesting service - http://drupal-builder.net - which I hope will help novice Drupal CMS developers speed up their learning in some ways. Essentially, it's online site builder where one can select from the list of top Drupal modules and generate Drupal site/installation on the fly. This allows to start playing with these components instantly. I am thinking about ways to make this service more solid and helpful.
Joomla-Builder - online tool for building a custom Joomla installation.
If you're using Joomla CMS or would like to be able to take a quick look into options it offers I would recommend the http://Joomla-Builder.com service.
It allows to create Joomla installation file with lots of cool 3rd party extensions.
Otherwise, you'd spend a lot of time investigating which ones are suitable for your needs.
Actually, it's a direct advertising since I am the creator of this online tool, but initially I had created it for myself. You see, it takes a lot of time to search for necessary Joomla extensions since not all of them are universal, not all of them are working properly.
Working with Joomla extensions, web developer has to deal with such extension aspects as
-SEF compatibility,
-JoomFish compatibility,
- relation of a given extension with Legacy mode in Joomla 1.5 etc.
Joomla Developer also has to maintain latest versions of extensions on local drive to be able to pull them out for use immediately etc. Installation of any extension also takes time. In other words, reality of Joomla development requires a lot of time and attention.
I decided to create something like a universal repository of popular extensions that you can automatically pre-install into the latest Joomla core with just one click. Essentially, Joomla-Builder as it looks is a form with a list of extensions and "Build" buttom, clicking which results in Joomla installation file with a list of selected extensions (components, modules, plugins, themes). Personally, I've never seen anything similar to Joomla-Builder and I even feel somewhat proud of my creature. Recently a 71 year old man wrote me a thank you letter, saying he never realized he would be able to create a site and how easy it actually is.
Currenlty in Joomla-Builder you can see such big players in Joomla market such as VirtueMart (online shop), FireBoard (forum), MorpheoShow( joomla gallery), PhocaGallery, Community Builder (to catch up with Web 2.0). All of them a FREE, of course. And a lot of smaller extensions that have proven to be good help for Joomla site builders. Also, e.g. if you want joomla gallery, you have a choice which one to pick.
While writing this article I realize I can say a lot more about how one can benefit from using Joomla-Builder and this will be the topic for the next post, which I think I will write very soon.
I don't think that Joomla is the only solution, but the more ready solutions (or RAD solutions like CodeCharge Studio) developer has at hand, the faster he can react to unique requirements of his clients. I belive http://Joomla-Builder.com adds some noticeable value to Joomla world. In particular, I liked the honest JB review by a former member of Joomla core team, Brian Teeman - http://brian.teeman.net/extensions/bob-the-joomla-builder.html
Comparing CMS products
Those who want to get a very concise and clear understanding of differences between
Drupal, Joomla, WordPress and Plone can easily gain this understanding from this honest and well-structured report.
http://www.idealware.org/comparing_os_cms/idealware_comparing_os_cms_rep...
More specificalyl, page 14 contains a very detailed matrix comparing these 4 CMS systems. I wish it somehow had CodeCharge Studio in the 5th column.
Improving CCS skills: advanced z-Index
If you think z-Index property is only about the 3rd dimension on your html page and layering elements one on another, you're fooling yourself. z-Index looks simple, but participates in a number of interesting rending rules.
And using z-Index implies a number of these rules, which can make the CSS-layout of your Drupal or Joomla template far more predictable and controllable.
The following article is deep and simple at the same time and really sheds light on subtleties of z-Index.
https://developer.mozilla.org/En/Understanding_CSS_z-index
