drupal module development

Changing Short project name in a Drupal.org project

Typical problem, you have just gained your full project permissions role in Drupal.org, and you make your first mess... you have promoted your so loved first project without changing the Short project name.

Well, you have a problem, but not too big. Drupal.org will not allow you to rename your Short project name, so you will have to create a new one if you don't want to have an ugly url like that: https://drupal.org/project/2062343

Fortunately git can help. You will simply have to:

  • Create a new project, sandbox or not,
  • Go to the "Version control tab" and get the url of your new git project, something like: programadoresweb@git.drupal.org:project/2062343.git
  • Go to the folder of your old sandbox, the project in which you cannot change the Short name, and change the remote for this folder. For my url example, the command will be: git remote set-url origin programadoresweb@git.drupal.org:project/2062343.git
  • Nearly finished. You probably have to merge, as you will have to make your first commit in the new project: git pull
  • And finally, git push origin master will get the job done.
  • Remember to create a new branch, like 6.x-1.x and commit to that one to create a new official, downlodable release of your module. Congratulations :-).

 

Next time, take it easy cowboy ;-).

 

More information:

 

Howto patch a Drupal module

Some contributtion to add to this Drupal module with which you have been working on?

Very easy, take note:

 

  1. Go to the folder of your module, previously cloned with git. For example, my contribution this morning: 
  2. git clone --recursive --branch 7.x-1.x http://git.drupal.org/project/cpn.git
  3. cd cpn
  4. Create a new branch, for example: git branch 1912834-weight
  5. Change to this branch to make the changes: git checkout 1912834-weight
  6. Make your changes
  7. Add them with: git add your-file-modified
  8. Commit them, git commit -m "comment your changes as much as possible"
  9. Create your new patch: git diff 7.x-1.x > cpn-weightsettings-1912834.patch
  10. That's it :-)

 

More info:

 

 

Get Drupal fields for a particular content type

 

Sometimes in Drupal you need to get the fields for a particular content types. 

"$type = 'mytype';

$fields = content_fields();

$type_fields = array();

foreach ($fields as $field_name => $field_data)

{

  if ($field_data['type_name'] == $type)

  {

    $type_fields[$field_name] = $field_data;

  }

}"

 

in drupal7 is easier, since we have a direct function:

field_info_instances($entity_type = NULL, $bundle_name = NULL)

 

 

get current drupal theme

very simple:

        global $theme_key;

      echo $theme_key;

 

if we need more information, we can use this:

       $themes = list_themes();

       $theme_object = $themes[$theme_key];

 

        // print all the object fields

       var_dump($theme_object);

 

via http://drupal.org/node/46961#comment-88354