Showing posts with label Drupal. Show all posts
Showing posts with label Drupal. Show all posts
Wednesday, July 10, 2013
Wednesday, December 19, 2012
Monday, December 17, 2012
Thursday, October 18, 2012
Sunday, September 2, 2012
Wednesday, August 29, 2012
Wednesday, June 6, 2012
Taxonomy add edit form simplified for client
I wanted to clean the taxonomy form for our client.
So i created one custom module. and here is my module file code.
function capo_form_alter(&$form, &$form_state, $form_id){
switch ($form_id) {
case 'taxonomy_form_term':
$form['name']=$form['identification']['name'];
$form['parent']=$form['advanced']['parent'];
$form['parent']['#weight']=1;
$form['submit']['#weight']=10000;
if($form['delete'])
$form['delete']['#weight']=10001;
$form['weight']=$form['advanced']['weight'];
$form['weight']['#access']=FALSE;
$form['parent']['#multiple']=0;
$form['parent']['#size']=1;
unset ($form['identification']);
unset ($form['advanced']);
//dsm($form);
break;
default:
break;
}
}
So i created one custom module. and here is my module file code.
function capo_form_alter(&$form, &$form_state, $form_id){
switch ($form_id) {
case 'taxonomy_form_term':
$form['name']=$form['identification']['name'];
$form['parent']=$form['advanced']['parent'];
$form['parent']['#weight']=1;
$form['submit']['#weight']=10000;
if($form['delete'])
$form['delete']['#weight']=10001;
$form['weight']=$form['advanced']['weight'];
$form['weight']['#access']=FALSE;
$form['parent']['#multiple']=0;
$form['parent']['#size']=1;
unset ($form['identification']);
unset ($form['advanced']);
//dsm($form);
break;
default:
break;
}
}
Friday, May 11, 2012
Decide Drupal or PHP ?
Both technology, has it's own potential, in their area. First I will brief about the both technology, and what is their area.
Drupal:
This is one of the strongest tool built for php developer. It comes with it's own code base(file & folders) and database. Not only that there are 15,993 third party modules(Free), 1,374 Themes(UI). So basically, Drupal is built with all the generic features which almost 70% web applications requires. Features like user accounts, roles, permissions, Admin CRUD, Generic report.Pros
- Development becomes very fast, since instead of writing code developer assembles drupal modules.
- Lot of features are already developed, it has a very active community, available for support.
- It is CMS cum Framework, so when require we can write our own custom module also.
Cons
- It has its certain core area (codebase & DB), that is not changeable.
- Even though, one can develop custom modules, but it has to follow drupal standard, which ultimately make a boundary for developer.
When to use drupal
- When we know we are going to build a generic web applications. Where things are straight forward.
- Client requirement are not stiff. Client is ready to accept our suggestions.
- When we need to make process fast.
When not use drupal
- When your requirement may break the drupal core system.
- When client is more cautious about the quality, rather than time or budget
- When you don't have right resource
PHP
PHP, is the Father of Drupal, and Father is always bigger than child :).
What ever we can do with drupal, i.e. also available here, with unlimited freedom.
This is pretty similar to command line of any operating system(like linux) and it's GUI alternative.
Pros
- Here since you start from scratch, you can plan your core DB & code base. From here your freedom starts.
- PHP also has its own very robust, mature community. these people don't write their contribution in a standard module. but they talk and write in some CMS or framework in which they are good. So you get support but nothing like plug n play module.
- As you are free to work in PHP, at the same time if you can google, and find(not guaranteed) something already written, and same(if not exactly then 80% same) as your project would be.
- Resources are easily available.
Cons:
- Compare to drupal, only thing which is lacking here is, some time for small thing. it takes too much time.
When to go with PHP
- When your application is using multiple technology.
- Client requirement contains lot of exclusive things. Like some client want to set a new trend with their application. Some time they want to beat Facebook, twitter and even google also :).
- When Your client use words, like pixel perfect, it should be in professional way or It's a common web standard, etc.
When to not go with PHP
- When Client asks suggestion from you, and you know you can mould in your way.
- In your application, there is nothing like you invent something from zero.
Other References:
Sunday, April 8, 2012
Drupal Menu
hook_menu() implementations return an associative array whose keys define paths and whose values are an associative array of properties for each path. (The complete list of properties is in the return value section below.)
Labels:
Drupal
Friday, March 2, 2012
Get the path to a Drupal module or theme
Suppose you have a image file in your custom module
Best way to take that image is
<img src="<?php echo base_path().drupal_get_path('module', 'module_name');?>/image_name.jpg" />
http://data.agaric.com/get-path-drupal-module-or-theme
Best way to take that image is
<img src="<?php echo base_path().drupal_get_path('module', 'module_name');?>/image_name.jpg" />
http://data.agaric.com/get-path-drupal-module-or-theme
Labels:
Drupal
Wednesday, January 11, 2012
Drupal custom status message on node submission
Drupal Content types are used for variety of features in a project. So when user submits a form, s/he gets a generic message "your "typename" has been created".
Best way to change these messages, and get a complete control over them is
function hook_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
global $user;
switch ($op) {
case "view":
global $_SESSION;
if ($_SESSION['messages']['status']) {
foreach ($_SESSION['messages']['status'] as &$value) {
if (substr($value, -17) == 'has been created.') {
switch ($node->type){
case 'contact_us_website':
$value = "Contact Us form has been submitted. We have received your comments - Hawaii Savvy Team";
break;
case 'report_problem':
$value = "Report problem form has been submitted. We have received your comments - Hawaii Savvy Team";
break;
case 'event':
if(!(user_has_role('Administrator') || $user->uid==1))
$value = "Your Event has been submitted. We will publish it very soon - Hawaii Savvy Team";
break;
....
......
For other ways look http://drupal.org/node/500202#comment-2210030
Best way to change these messages, and get a complete control over them is
function hook_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
global $user;
switch ($op) {
case "view":
global $_SESSION;
if ($_SESSION['messages']['status']) {
foreach ($_SESSION['messages']['status'] as &$value) {
if (substr($value, -17) == 'has been created.') {
switch ($node->type){
case 'contact_us_website':
$value = "Contact Us form has been submitted. We have received your comments - Hawaii Savvy Team";
break;
case 'report_problem':
$value = "Report problem form has been submitted. We have received your comments - Hawaii Savvy Team";
break;
case 'event':
if(!(user_has_role('Administrator') || $user->uid==1))
$value = "Your Event has been submitted. We will publish it very soon - Hawaii Savvy Team";
break;
....
......
For other ways look http://drupal.org/node/500202#comment-2210030
Monday, January 2, 2012
Converting Timestamp into calendar-clock time values
Dupal and other PHP open sources store time as timestamp into database.
So, while working or debugging on such DB tables, one has to convert it into calendar-clock time format (mm/dd/yy- hh:mm:ss). Reason could be anything.
For this, either write your own php code or use this tool
Unix Timestamp Converter
You should know timezone of your web application.
In drupal 6 it is in admin/settings/date-time
Now to get the GMT offset of this timezone one can use
The World Clock
Type the city name in search city field. Go to city page.
Here you can find your timezone's GMT offset.
So, both tools together helps you to undertand your db table time values.
So, while working or debugging on such DB tables, one has to convert it into calendar-clock time format (mm/dd/yy- hh:mm:ss). Reason could be anything.
For this, either write your own php code or use this tool
Unix Timestamp Converter
You should know timezone of your web application.
In drupal 6 it is in admin/settings/date-time
Now to get the GMT offset of this timezone one can use
The World Clock
Type the city name in search city field. Go to city page.
Here you can find your timezone's GMT offset.
So, both tools together helps you to undertand your db table time values.
Monday, December 19, 2011
Drupal | Performance
Suggested urls on drupal performance
Friday, December 9, 2011
IE Unlimited CSS Loader
IE Unlimited CSS Loader
if you use drupal cache's option to optimise css files, all your css will get merge into one. so no need of this module
if you use drupal cache's option to optimise css files, all your css will get merge into one. so no need of this module
Wednesday, November 30, 2011
Tuesday, June 28, 2011
Drupal | programmatically create node with file field
$node = new StdClass();
$node->type = 'bzl_img';
$node->uid = $_GET['user_id'];
$node->field_bzl_img_ref[0]['nid']=$_GET['bz_id'];
$node->status = 0;
$node->field_bzl_img_main[0]['value']=0;
$node->type = 'bzl_img';
$node->uid = $_GET['user_id'];
$node->field_bzl_img_ref[0]['nid']=$_GET['bz_id'];
$node->status = 0;
$node->field_bzl_img_main[0]['value']=0;
Wednesday, March 2, 2011
.tpl file output using theme function
So, you have prepared the output in one of your module function with all complicated business logic client specified in last meeting. Your "return ($output);" throws everything on screen. You became glad to see your code worked finally.
And if Table layout is required you pushed all html in $output variable and theming of your own module page become hectic. Better to go with tpl output.
And if Table layout is required you pushed all html in $output variable and theming of your own module page become hectic. Better to go with tpl output.
Sunday, February 20, 2011
Drupal menu explained
View more presentations from Amit Kumar Singh.
Subscribe to:
Posts (Atom)

