//

IF statement in programming

I don't know about the programming language you are dealing with but I would say that most of them will handle the IF statement in the same way and it has always bothered me. Specially when there seems to be no way to avoid using it for a specific circumstance.

For example lets say you want to run a set of actions depending on the value of a variable:

ActionScript:
    if (variable == true) {
       //then to all this
    }

I am trying to figure out a way to avoid this set up specially when you are re-using a set of functions but you always have to test for the value of a variable.

Another example would be a game, if for example you have 1000 units and all of them will have a state of "sit" or "standing" given their "position" property. Now you have a 1000 units that will be testing "if they are sitting or standing". I know this issue can be solved with the set up of the application rather than the IF statement but it is to give a clearer example of the issue.

Lastly I think it bothers me the most with Singletons. Most of the singletons you have to test for a property to define if you are going to create a new instance of the Singleton or if you just going to use the current instance.

How much overhead is this for the processor? Minimum? Nothing? I am assuming its almost nothing and that is why Singletons are so popular, althought we know some people believe that Singletons are _root in ActionScript which make more damage than helping. But that is besides the point.

If you have some ideas on how to improve the use of the IF statement let me know.

//

Keep Me Out – for a short period of time

KeepMeOut is a site with an interesting concept. Basically the site allows you to block yoursef from sites you specify for short periods of time.

PROS:

  • Gate keeper for short periods of time
  • Time tracker

CONS

  • You have to create a bookmark for every site you want to "block"
  • If you use multiple browsers you have to manually sync your bookmarks - unless you use something like foxmarks
  • You can get around this by typing the address on the browser

Still if there is that little site you are struggling with (meaning you visit ALL the time) this might be worth giving it a shot.

Visit the site

//

YouTube Will Be Next To Kiss IE6 Support Goodbye

Accordingly to TechCrunch YouTube will stop surpport for IE6.

"Judging by this screenshot taken by an IE6 user who was watching some videos on YouTube, it appears the Google company will be phasing out support for the browser shortly. I don’t have Internet Explorer 6 installed on my computer, so I can’t verify this first hand, but illogical it seems not and a simple Twitter search shows multiple people confirming the news. Heck, some are even downright ecstatic over the news."

For many developers it has been a nightmare to apply hacks to their code to make design fit IE6 standards and this move might help other big players help users upgrade their browsers and make the web a "better" place. With YouTube encouraging users to install other browsers such as Google Chrome or FireFox we can only hope that people understand that Internet Explorer is just a piece of software that that there are other alternatives for online browsing that give you a better experience.

//

WordPress VS Drupal User Management

Having the ability to create different users and give each a different role is one of the most important things within a CMS, you need to be able to control all aspects of the site (super users) and also give other users the ability to control display or content within the site without breaking it.

In our CMS test I will have 6 type of users.

  1. Super Administrator:
  2. Responsible for all the aspects of the site, create/delete/edit/publish/unpublish content, change themes and create or edit other users

  3. Site Administrator:
  4. Responsible for create/delete/edit/publish/unpublish any content from the site, change themes, create or edit other users but is not able to change the layout of the site.

  5. Author:
  6. Creates/edits/publish/unpublish own content.

  7. Editor:
  8. Creates/edits own content but can't publish the content, they notify the Site Administrator to do so.

  9. Subscriber:
  10. Receives notifications when site content changes and is able to comment on content if content is enabled to receive content.

  11. Visitor:
  12. Access to all content that is published but is not able to edit any part of the site

WordPress and Drupal do a good job in allowing you to create different kind of users and this is where we start to see some separation between the two systems and this might be one of the main reasons why you may choose one after the other but lets see them in detail:

WordPress:

WordPress comes with 5 predefined roles (or user types) and one user, WordPress has a page that explain the roles in great detail but lets see their "Summary of Roles"

  • Administrator - Somebody who has access to all the administration features
  • Editor - Somebody who can publish posts, manage posts as well as manage other people's posts, etc.
  • Author - Somebody who can publish and manage their own posts
  • Contributor - Somebody who can write and manage their posts but not publish posts
  • Subscriber - Somebody who can read comments/comment/receive news letters, etc.

This is great specially when you are starting and you want to create your content and define users rather quickly. In the default installation since I was the one installing the software I was automatically added as a site Administrator.

WordPress_Users_Default

I went ahead and created the different users that we need and with WordPress was a breeze since the roles were already defined as an option.

WordPress_Users_Added

There was one major issue with the default set up and that is the Administrator role could not be edited in a way that the role was not able to edit the layout of the site. So I still wanted the site administrator to have full control of the site content and users but not to have control of the layout. I am sure I could go into the database and alter this setting by creating a new role and applying new rules but for this experiment I am not going to go that far. I went ahead and did a quick search in Google for a plugin or similar that would allow me to create custom roles and there were about 21,500,000 results on my search (wordpress+custom+roles), so it seems to be some sort of demand for the feature.

Drupal:

Drupal has 2 predefined roles and one user each of the roles are explained within the role's page:

  • Anonymous user: this role is used for users that don't have a user account or that are not authenticated.
  • Authenticated user: this role is automatically granted to all logged in users.

Here is where we start to see a small gap between WordPress and Drupal. Drupal allows you to create custom roles where you can define and alter the different access levels for the users. Drupal starts to show some "muscle" here by giving you different categories for User Management, such as Access rules, Permissions and User settings.

Drupal_Users_Roles

Drupal_Users_Default

Creating roles has a lot of advantages because you can customize exactly what each user is allowed to see and do, but also you are responsible for what you allow the user to do. It is a good idea to create test accounts that will allow you to see what the new role will be able to access.

Drupal_Users_Roles_Edited

One more benefit for Drupal users is that you can customize the different emails that the user is going to recieve when new accounts are created, forgot password, no approval required, awaiting approval, blocked email and deleted email. For many of us this might not seem like a huge benefit but if your CMS is going to have your (or your client's) personality, it is great to see that you can customize these type of details.

If the administrator creates a new account you have an option to notify to the user of their new account, WordPress doesn't have this option.

Drupal_Users_Added

We can see how both systems have their own way of handling user management and it is evident that when it comes down to a robust CMS where you need detailed user management Drupal gives you the flexibility you need. WordPress is the "out-of-the-box" solution that allows you to create predefined users, in a blogging environment this is perfect but for a more complex setup you will need to rely on plugins or hack the software directly.

to be continued (templates)

//

Disable extra fields in CCK for Drupal

There are times when you want to allow the Super Admin to edit those extra fields but not the editors/contributors of your site so this is one way to do it:

PHP:
    < ?php
    /**
    * Change the node form
    */
    function phptemplate_node_form($form) {
      // echo "<div style='direction:ltr;'>"; dprint_r ($form); echo '';
     
      // Hide 'Log message' text area
      $form['log']['#access'] = FALSE;
     
      // Hide the author collapsable box
      $form['author']['#access'] = FALSE;
     
      // Hide the publishing options collapsable box
      $form['options']['#access'] = FALSE;
     
      // Open the file attachments collapsible block in a full state
      $form['attachments']['#collapsed'] = FALSE;
     
      return drupal_render($form);
    }
    ?>
//

WordPress VS Drupal Creating Content

One (if not the most) important subject in any CMS is going to be creating content. You want to be able to allow you user to create content quickly and efficiently, while at the same time the developer wants control over how the content is going to be displayed in the front end.

Creating content in Drupal

Drupal Creating Content 1

Creating content in Drupal is very straight forward and I really like how they explain each default section. Immediately you can tell Drupal is not worried about winning the Blog wars since they do not even have a blog option as part of their default system. Although you can use the "story" as a blog post ("and informal blog-like entries may all be created with a story entry. By default, a story entry is automatically featured on the site's initial home page, and provides the ability to post comments.") and they also have a Blog module but is not one of their default settings.

Drupal Creating Content 2

Here is the default view for a Page in Drupal, straight forward that allows you to enter the Title and Body of the page. One draw back on this default interface (at least in my point of view) is the simplicity of the page, we do want simplicity but right of the back you cant upload pictures or have a pretty interface that you can use to edit test, which a lot of people have been accustomed to. Again, that is my point of view as if I were to give this application to a client as it is they probably would feel the same way.

On this page you can also allow the page to be part of the main menu or leave as is and you can enter HTML (something that can be changed and more about that in a different post)

You also get to create the revisions for that specific page and view/revert in the future if you desire to do so.

It is important to note that as these settings are optional and you can turn them on or off depending of your specific needs for the content. You also get a preview of the page with all the edit section at the bottom of the preview and then you can save to make your page live.

Creating content in WordPress

WordPress Creating Content 1

WordPress is a content-creation machine, as soon as you login to the dashboard you can do a quick-post which is similar layout to what you find in Drupal but immediately you are able to also upload media such as images, video, sound or media in general. Right away you can tell why WordPress is so "loved" in the blogging community.

But again, I need to create a page and that is one of the options in the main navigation bar. Create pages is 2 clicks away (1. Pages and 2. Add New)

Some of the features in WordPress is that you have the usual interface when creating content even with spell check. Which it was not available by default in Drupal. Also you are able to switch from Visual and HTML for the users who want to take advantage of that functionallity.

WordPress Creating Content 2

Another nice feature is that WordPress will save Drafts as you are editing your Pages, which allows you to keep the content you are working with in case something goes wrong with your computer, lose internet connection or are in the run.

You also are able to upload media in this section and create custom fields. Custom fields are used for more advanced site layouts that need this extra information to make your layout unique. Here is some information about custom fields. Can we create custom fields in Drupal? Absolutely but we are just covering the default behaviors in WordPress at the moment.

One more thing that WordPress does well, is providing feedback and information that to some might be overwhelming but that it is informative for the user such as word count and when the last draft was saved.

You can preview your changes which will be launched in a new page with your theme in a very realistic manner. Drupal does something very similar but all the editing tools live under the items you are reviewing.

Continue to WordPress VS Drupal User Management

//

WordPress 2.7 Demo From Matt Mullenweg

Tags:

//

WordPress Vs Drupal Installation

Download and installation for both was a breeze. Granted Drupal gave me a little bit more of problem since I had to create new directories and set the right permissions to the newly created directory and a settings file.

On the other side I also had to create a file in WordPress directory. Here are the steps on more detail

WordPress Installation

WordPress_271

  1. Download WordPress
  2. Upload to server with FTP program
  3. Duplicate/Rename wp-config.php file (you can also let WP do this for you)
  4. Update settings in the file such as Database/Login credentials
  5. Add new Authentication Unique Keys*
  6. Enter Blog Title and your email
  7. Receive your Username and Random password.

WordPress Success Page

*It was nice that WordPress has a site dedicated in creating those unique keys and no way around it, once you hit the site you get the set of key numbers you need and continue working.

Drupal Installation

Drupal_610

  1. Download Drupal
  2. Upload to server with FTP program
  3. Create 2 files and set permissions to them (settings.php & /files)
  4. Enter database information on online form
  5. Submit Username and Password for admin and set some other basic settings such as site name

Drupal Success Page

Here you have it, the installation in a few number of steps for more advanced users. Granted, for some one that has never installed any package maybe you will have to browse around and find answers to basic questions but in the end you should be able to acomplish the same task in this few steps.

Continue to WordPress VS Drupal Creating Content

//

WordPress VS Drupal Intro

WordPress VS Drupal has been done, I know. Just by running a simple query in Google you will get a lot of information in the subject but for me it was still not quite what I was looking for. For one thing, I don't know much about the people who made the reviews or their credentials and some reviews lacked the basic information I was looking for.

To start let me give you some of my professional information so that you know who I am and where my review is coming from.

12+ years in Web Development
WordPress user since 2003
Drupal noob since April 2009 (about 5 days at the time of this writing)

Programming Languages and Frameworks that I either use or I have experimented with: ASP, PHP, AS(1-3), Flex, Objective-J, JQuery, JQueryUI, CodeIgniter, Kohana (fork of CI), Zend Framework, AMFPHP, HTML, XML, JavaScript, CSS, and more...
Online packages that I have worked with: WordPress, b2b, MovableType, Habary, Mambo, Joomla, SugarCRM
I would also like to note that I have created my custom CMS for clients, couple have been done with pure PHP and some with the aid of a framework such as CI, or Kohana. Also I have been fortunate into creating CMS that would have Flash front end and PHP/Framework backend.
Writer: 0 experience, just my blog .

(Disclaimer: I am not here to defend the packages themselves)

Now with that aside, I want to take a minute and put WordPress VS Drupal in a small duel where I will register my findings and give some feedback in different aspects of both pieces of software such as installation, upgrading, templates, 3rd party elements integration and whatever else comes along.

Continue to WordPress VS Drupal Installation

//

JQuery and dynamic elements

I have been working with JQuery on a couple of work and personal projects and I really like the library. One of my first challenges was to access elements dynamically and at the same time trigger custom events. This is specially necessary when working with elements where you don't know the source of the data in detail.

Here is a sample as a reference:

JavaScript:
    $(document).ready(function() {
             
             var idTotal = 5;
             
             for ( var i = 1 ; i < idTotal ; i++)
             {
                var deleteMinutes = $("#deleteMinutes_"+i);
                attachEvents ( deleteMinutes ) ;
                
                var updateMinutes = $("#updateMinutes_"+i);
                attachEvents ( updateMinutes ) ;
             }
             
           });
          
          var globalID;
          
          function attachEvents ( $item )
          {
             $item.bind("click",       clickHandler );
             $item.bind("mouseenter",    hoverHandler );
             $item.bind("mouseleave",    mouseleaveHandler );
             $item.bind("mousedown", mousedownHandler );
             $item.bind("mouseup",    mouseupHandler );   
          }
          
          function clickHandler ( $event )
          {
             var target = $event.target.id;
             var id = target.charAt(target.length-1);
             globalID = id;
             $('#dialog').dialog('open');
          }
          
          function hoverHandler ( )
          {
                $(this).addClass("ui-state-hover");
          }
          
          function mouseleaveHandler ( )
          {
             $(this).removeClass("ui-state-hover");
          }
          
          function mousedownHandler ( )
          {
             $(this).addClass("ui-state-active");
          }
          
          function mouseupHandler ( )
          {
             $(this).removeClass("ui-state-active");
          }
          
          function deleteItemSelected ( )
          {
             $("#minutes_"+globalID).remove();
          }