Friday, June 21, 2013

Treehouse learn to make ios apps, android apps, web design and programming.

Searching more for a way to pick up my design skills being a programmer and all I came across this treehouse site ( link is below )

Just started today so I won't have a deep review but here's what I like and dislike:
  • I like the why it is set up, building from the scratch up. Other sites I cant really find a start point and I and up not looking into the trainings. 
  • You can take a quiz or code challenge along the way. first of all for me it's checking if I already own those skills of if I should check in to this in a few seconds.
  • Second, you earn badges which may be a bit childish but I think it's fun. Also potential employers can see the badges you earned. And last it gives you hands on practice while you try out new stuff you just learned.
  • As you progress you can view on your dashboard where you are in the courses. So you can easily pick up any time where you left off.
  • There is a litte bit of humor in the video's which I think takes the edge of some things and makes it a nicer learning experience.
  • Now what I don't like I have to think about... Maybe it could have been a bit less childish ? If I come up with some thinks I'll add the likes and dislikes later to this post
The prices are ok I have to see if this is really for me but looked at a few and I must say I love it so far!
It starts from 25$ a month or 250$ if you pay annually ( 2 month discount ) for the silver account.
The gold account is a bit more pricier but I think you will have enough with the silver account.

Also you can earn 20% discount for every subscriber you refer, which is what I'm doing right now ;)
And I would appreciate It if you used my subscriber link. I'll give you the 20% discount I will be getting for the first year back if you contact me.
But other than that I still think it's a good think. Check out the free trial video's and see why I like it.

So check it out the link is in this join me on treehouse image below:

Create one time login link from the command line using drush no need to reset your password

I don't use this command as much but when I need it I always forget what this string of code was.

So I'll post it on my blog :)

The magic:
drush uli

Or if your targeting a specific user:
drush uli username

Using drush you can create a one time login link for a user or admin.
This is especially usefull if you want to login to the site without changing the password.
For example if you have a client with a drupal site that doesn't know the administrators pass or doesn't want to change it because you need it.
This can also be used to change the password if you don't know where the password reset link would be send or don't have access to the email address ( anymore )

Wednesday, June 19, 2013

Creating a link field programmatically for a profile2 user entity and deleting it upon disable or uninstall

In this example I have a profile2 profile called "werkgever"

The field I'm creating is a field used for that profile to input a website link.

required modules are

My module name is more_werkgever_fields

Using hook_enable I create the field:
 * Implementation of hook_enable().
function more_werkgever_fields_enable() {
  // Check if our field is not already created and if not create the field.
  if (!field_info_field('field_website')) {
    $field = array(
        'field_name' => 'field_website',
        'type' => 'link_field', // text

    // Create the instance on the bundle.
    $instance = array(
      'field_name' => 'field_website',
      'entity_type' => 'profile2',
      'label' => 'Website',
      'bundle' => 'werkgever',
      'required' => FALSE, // default: FALSE
      'settings' => array(
         // Here you inform either or not you want this field showing up on the registration form.
        'user_register_form' => 1,
      // 'widget' => array(
      //   'type' => 'link',
      // ),

This needs to be put in your modulename.install file

Also in the .install file you can implement a hook_disable or hook_uninstall
hook_disable is called when you disable the module. So this is handy if you are in a developing stage.
Just disable de module and your field should be gone.
An implementation of hook_disable:
 * Implements hook_disable
function more_werkgever_fields_disable(){
  // removes field when module is disabled
As said this goes into your module.install file as well
Finally there is the Implementation of hook_uninstall:
 * Implements hook_uninstall
function more_werkgever_fields_uninstall(){
  field_delete_field('field_website'); // removes field from the system
The uninstall hook is only called upon uninstalling the module. I recommend putting your delete field in here. Or don't delete your field. Depending if your your module can be reused by others and maybe causing problems if that field is to be deleted. In my case I don't want it to clutter my database so I put it in my uninstall hook.