Friday, September 16, 2011

How to identify if a comment is a reply to a parent comment in Drupal ?

It is pretty simple, but didn't find it listed anywhere,

if($comment->pid ! =0 )
{

//This is a reply to a comment
}

This will come in handy if you want to format a comment reply differently from a parent comment. eg - I had to hide the subject lines in comment replies to avoid too much chatter on the page. However the parent comment was still to have a subject line and hence I could not use the Drupal setting of disabling 'Subject on Comment' under the comment settings.


I now do capture the auto comment titles generated by Drupal on the comment replies but do not show them as in most of the cases, it is redundant with the comment reply.

Hope this will help developers looking for it and save some time !

Book Review - How to have kick ass ideas ?

How to have kick ass ideas ? is written by Chris Barez Brown. The book is a wonderful read for people bored of their routine life and people who are just passing their life, unable to enjoy every moment.
Chris mentions a few examples like - Do you have those Monday blues ?,  Do you feel like life has come to a standstill ?,  Do you wish weekends were longer ? are so common amongst all of us.

I have seen them regularly on my facebook and twitter updates. People are so stuck in their lives without even realizing. The book is a recommended read for them.

Whoever said that children books are more of pictures and less of matter, I read novels which have endless text. This was a great book with its crisp paper quality and lot of imagery. The presentation strikes right into your heart and mind.

It is well organized with the initial chapters identifying the problem and making you realize what you are unable to fathom. The rest of the chapters work through solutions, methodology and  a lot of examples.

Chris explains his story in the first chapter and engages you in his journey of self discovery and change. Then on, you want to listen to how he found his interest, how he changed his life and also the other real life examples.

I would give the book a 4/5 and is a quick read for all the 30 something nearing mid-life crisis folks.

Thursday, June 23, 2011

Vision for your website

While owning a website, it is very important that the product owner has a vision for his product ! If the product owner is of the kind who very frequently changes the design of the site, it annoys the team.
Under the influence of the social networks and a flurry of information coming your way everyday (thanks to the internet and the information sharing tools), it becomes all the more important to form your vision and not alter it frequently.
If a product owner say John is the owner of a site. John has 3 business analysts working under him helping him formulate the requirements. He has a development team working on the site. Even in the days of super fast agile and SCRUM and adaptable teams, it is important that the team gets to work on a story for sometime. John should courage and confidence in his team and let the team implement a certain feature.

 But consider this hypothetical case, John is addicted to Twitter and NYtimes.com. That is how he begins his day. When he comes to work, his mind is much used to these sites and keeps tracking all updates, functionality, usability changes, etc. When he opens his site, he now wants to have those same features there.

He calls the business analysts and tells them to design a feature like twitter, feature like the news widget, and so on. This design based on other sites is killing creativity. Also, the dev team who was working on certain features like forums now has to redo the site and make it accept only 140 characters because twitter does so.
The team is no longer interested in building the site for John because they know that tomorrow he might want to build something like foursquare.

This influence of other sites is creating a cluttered product and just too much overlap between all the different tools in a organization. Probably too much of information sharing has limited a person's identifying capacity and ability to focus on a plan for sometime.

At the end neither is John going to be happy with his site nor are the end users going to be able to it.
A word of caution -
Carry an exercise to create a vision for your product for atleast the next 5 months and stick to it. Believe yourself and do not alter it under the influence of other sites / products hastily.

Let the mind be focused and learn to stay focused...

Sunday, December 5, 2010

Rules vs Drupal action-triggers

Today I came across a strange issue in my app. I am using Drupal 6.19, Apache 2.2, PHP 5.2

Scenario 1:  Standard Drupal install with trigger module enabled.
I had  a custom action defined as below:
function mymdule_rules_action_info(){
    $info[mymodule_updateUserInfo] = array(
        'type' => 'user',
        'description' => t('Change user role'),
        'configurable' => FALSE,
        'hooks' => array(
        'user' => array('insert'),
        )
    );
    return $info;
}

function mymodule_updateUserInfo(&$object,$context= array()) {
//Check conditions here and add a specific role to the user.
}


I then saw my action listed under the admin > site configuration > actions page.

I set a trigger on the event of 'User has been created'  to run the above action of  'Change user role'.

So when a new user was added to the site, this trigger was evaluated and the role of the user changed as applicable.


Scenario 2:  Trigger + Rules 6.2.x
On setting up the rules module and using it for some other content based event - triggers, the above action stopped working.
What I noticed was that some other user saving hook was overriding the custom action and resetting the user roles to empty.
I tried using rules module to execute the above custom action on the user has been created event, but that did not help.

Solution: I changed the above action to run on the User has logged In event and that seemed to work. Now there is a overhead that this rule will be executed everytime a user logs in.
Not sure if the rules module event of User has been created does not function correctly.

Advantage of rules : More configuration and no customization.

Tuesday, November 30, 2010

Drupal plugin for eclipse

Looks very promising. I have started using it and looks great. I would love to have a unit test support integrated with the Drupal IDE.

I am using it with Apache 2.2, PHP 5.2 and eclipse helios.

Discussion : http://groups.drupal.org/node/39938

Saturday, November 20, 2010

Testing is the key

In one of my projects, we are having a tough time ramping up the team for Drupal. Drupal is mainly about :
  • modules
  • hooks
  • themes
  • templates
  • overriding over overwriting

We have had the team undergo:
A week long in person training on Drupal. This comprised from basic Drupal architecture, evaluation of modules, themes  to advanced topics like crerating modules, customizing modules, templates and overriding functionality.

The team is still not confident about facing a problem or feature and building a solution. Tthe management now needs to think about how to tackle the situation and bring the team upto speed and ensure that a quality solution is delivered now and everytime.

As a technical analyst and a Drupal developer, I am trying to understand, why is the team taking so long and while the team is still learning to come up to a benchmark, how do we ensure the quality of what the team is working on.

A few options that crossed my mind :
Have a senior developer on the team work closely with the team (unfortunately no budget)
Have a mixed team of 1 senior developer and 1 junior developer (unfortunately no such developer is available)
Have a dedicated person to test the changes thoroughly (since this is a support project and with no detailed functional / requirement documents, the testing team is not ready to own it)


I understand that this is more of a people issue and no one is ready to own the project and ensure quality deliverable. I now think that had the project had tons of unit tests, developers, testers and customers would have been at peace right now.

Unit tests are a key to a project with not many documents, worked upon by new developers.  Drupal does not have many unit tests with the modules and TDD with Drupal is not so straight forward.

I will post my experience with unit tests or automation tests and Drupal more in the coming weeks.

Friday, October 15, 2010

Drupal Redesign - Nice !

So guys, drupal.org is undergoing a redesign for sometime now. And I must say the new site is very commendable. What I liked about the site :
  • Fresh UI
  • Easy navigation
  • Personalized dashboard comparable to elgg tool
  • Improved organization of tutorial
  • and much more
I am enjoying using the site and will report any issues to the queue. 

Heres the url - http://beta.drupal.org/