Showing posts with label drupal. Show all posts
Showing posts with label drupal. Show all posts

Monday, April 30, 2012

Where is my drupal project?

The last posting i made was on 10th April, and it has been almost 3 weeks i haven't touched my drupal. This is bad. If i keep on going through this this life routine without having highest concern in my mind on my project, rest assured it will be doomed as always. i need to make some amendments. i cannot go on following slow process like this. A drastic change must be done!

Tuesday, April 10, 2012

Nuisance in drupal module writing

What i hate most about writing drupal codes and want to see it live is; every time you add/change new codes even if they are short ones you need to disable and enable that specific module. It's not like drupal provides a button or link at each module where you can simply reset, they don't have this simple shortcut. This matter has becoming a nuisance already for me, and it makes worse when your computer like mine is a fucking slow unrealiable-sonnomabitch-machine. It'll take ages if i were to see the complete outcomes based on the final codes.

i wish there is some kind of mechanism or technique that i never need to re-enabling & re-disabling modules each time i update the codes. It should be just live changes onscreen without a need to reset once you have done with your errorless codes

Monday, April 9, 2012

How to display something onscreen - using menu & form

How do you write anything on drupal framework page

as of now, what i have learnt in order to type or to display something onscreen are as follows:

  1. i can use command hook_help(). Need to pass 2 variables; eg buat_sendiri_help($path, $arg). In order to display something onscreen, i must use return *text*, otherwise nothing will be displayed.
  2. Use command hook_block_view(). need to pass a variable; eg buat_sendiri_block_view($delta=''). In this hook command, i need to assign the key name 'subject' and 'content'. Any assignments to those keynames (subject & content) will be displayed inside the block region. Same thing as hook_help(), i must return value at the end of the hook_block_view(). Anyway, the earlier step that must declared before using hook_block_view() is to use hook_block_info(); this is for declaration purpose where i assign the unique name of the block & some key name values. Eg of assigning unique block name is $block['buat_sendiri'].
  3. Use command drupal_get_form() where i need to pass a custom function name inside the brackets; eg drupal_get_form('buat_sendiri_contents'). However, inside my tutorial, the way of the coding calls drupal_get_form() is via another hook function called hook_menu(); eg buat_sendiri_menu(). I create an associative array where some keynames of the array are assigned with values. The keyname to call function drupal_get_form() is 'page callback' => 'drupal_get_form', and 'page arguments' => array('buat_sendiri_contents'). In short, the way of assigning values to keynames 'page callback'=>'drupal_get_form' & 'page arguments' => array('buat_sendiri_contents') is equivalent to triggering function drupal_get_form('buat_sendiri_contents').

    Like typical hook functions, i must return the value *form* at the end of line when using drupal_get_form(). Here for more info on drupal_get_form(). How do i return *form* is by using system_settings_form($form).


SO, the question bungling in my mind currently is; how can i produce any contents without a need to go through help, menu or block? Anyway is this a valid question?

variable_set(), variable_get() and system_setting_form()

Some explanations on the use of variable_set(), variable_get() and system_setting_form().



You can get the complete info here.

mental note on drupal form coding

This is a mental note for me to do. I need to make a summary of what are the things that i've learnt when developing form in drupal. Until now, i can only summarise that there are too many complex commands that require me to understand. So it's better if i can summarise them all in a single illustration so that it's easier to mentally digest.
.

Friday, April 6, 2012

Writing drupal module - Form creation

After 3 days have passed, i finally able to continue my drupal module coding. Today, what i did is creating form elements inside drupal site.

The order of creating form in drupal is like this:

  1. use command 'page callback' where its value is the key function in drupal called drupal_get_form()
  2. use command 'page arguments' whose value is an array that contains a value referring to a name of function (must use underscore in a single word, eg: nama_saya_shahrul. this value - nama_saya_shahrul will be passed to key function drupal_get_form() for drupal to process the form.
  3. Create function nama_saya_shahrul($form, &$form_state), this is just an example.
  4. use variable array that has the followings (make sure you never miss out the hash)


    • #type
    • #title
    • #description
    • #default_value
    • #size
    • #maxlength
    • #required

  5. Need to use another drupal-specific function called variable_get('nama_textfield',default-value). I think variable_get() is similar to session() or assigning value to hidden form field where we can retrieve them later on.
  6. last but not least is using system_settings_form($form) function.

And the following videolog is the output from the new codes

Monday, April 2, 2012

Trouble shoot drupal menu module - successful

There is something not that clear about the explanation on using the function hook_menu() and its associative array keyname as in the drupal doc site. There is one particular passing variable that i do not understand how it's used and how does it pass values to other created custom function namely current_posts_form(). The key function used here is drupal_get_form(), it is only used once in the hook_menu() but does not have its own function declared in my codes.

Below is videolog that shows how i managed to point out the error i made. Anyway, frankly speaking it is actually not a programmatical errors but it is simply because of the function callback declared inside the associative array that is not declared inside my codes. So, whenever drupal core program searches for the callback function and it cannot find one, that's when it produces such error.



in a nutshell what i did to rectify the error was; i create an empty function content_posts_form() so that drupal core program can pick it up although it does nothing, so when reset the module (deactivate & reactivate) the content shows no error but with empty content body.
.

Writing drupal Module - Menu

Today i managed to make an uninterrupted time solely to write another drupal module. This is specifically to create a link at the menu region on the LHS of the site.
However, since there are still errors that require me to debug; i still do not where and what it is, so i just upload the so-called first part of the videolog writing a menu module. This is quite long video with 10min duration.



the following is the error produced from the module that i wrote:

Saturday, March 31, 2012

What i have learnt - 1st drupal module




PDO php in drupal

When i was reading about connection to dB in drupal, i come across a lot of unsual & unfamiliar connection method in drupal that has something to do with PDO. So ichecked in php.net & google it. So, this is what i found; PDO is one of php techniques in connecting to database regardless of its type (MySql, Oracle, Postgress). Anyway there is not much doc about it in php.net. there are few references in other links though as follows:

  1. http://www.kitebird.com/articles/php-pdo.html
  2. http://www.phpro.org/tutorials/
  3. http://developers.sun.com/

Friday, March 30, 2012

Plan for weekend


  1. Going to the gym with intention of at least accomplishing 400kcal burn. This should take around 2 hrs with cardio and weight lifting routine. - accomplished
  2. Cooking for the following entire week. I guess the usual chicken curry would do. i have already took out the frozen chicken outside, hopefully by the time i come back from the gym, the meat is already soft, good for cooking. - accomplished
  3. Targeting not to spend any single penny. Today is the last day of this month so i hope i still can meet the target. Speeding money for kitchen stuff and others can only start tomorrow. - accomplished
  4. Spend at least 2 hours on my piano; i have made myself familiar already with the LHS and RHS notes, it is just to bind them together mentally. This requires left and right brain practice, together with the coordination of my fingers.
  5. i must start off reading on form documentation and produce some videologs on my form creation in drupal. My target for today is at least one videolog is uploaded to Youtube for reference.
  6. hopefully at nite, i'm able to iron up all my shirts for office use. - accomplished
  7. Last but not least, changing water for my mind blowing aquarium. As of now, because of my own procrastination the water level has dropped to a two third. The plants are still growing healthily though, but the aqua-scene that looks not so neat that is now slowly getting into my nerve.- accomplished


Thursday, March 29, 2012

Downloading module Devel



I'm still searching for one page that tells me about a good practice of installing 3 modules in drupal for debugging purpose. Until now, i have no clue where i have read the page.

Damn!

Wednesday, March 28, 2012

Writing drupal module - block with database connection

this is a continuation of my codes done previously to create a block region on right hand side of drupal framesite where it shall display list of contents. This videolog in particular shows the code for database connection via command db_select()->...


In summary, what i've learnt from this exercise are:

  1. writing custom function for buat_sendiri module; this has nothing to do with hook() functions.
  2. Using php time functions; such as getDate(), mktime(hr, min, sec, month, day, year), time()
  3. *** most important command - Using db_select() class. the usage is => db_select('table_name','alias')->fields('alias',array('table_field')->condition('table_field',value)->orderBy('table_field','ASC/DESC')->execute(). an array variable should be assigned to db_select()


Below is the doc on getdate() that i extracted from php.net. The values return are used in mktime().




.

Tuesday, March 27, 2012

Writing drupal module - block

I finally completed making a videolog of a tutorial on writing drupal module that i've re-did this for the 3rd time. The earlier 2 videos that i have produced are lengthy so it's difficult for me to produce a nice watchable video for Youtube. So i made few attempts just to ensure that the outcome of the video is short enough for viewers to watch and requires reasoanably short time to upload to YouTube.

Anyway, the complete codes are still not enough because it still require the retrival of info from drupal dB and codes on presenting the content inside a block.
.


This is the summary of what i've learnt

Monday, March 26, 2012

PHP.net function link

This is the reference of all PHP functions as in php.net.
http://www.php.net/manual/en/

Thursday, March 22, 2012

Jomhosting Lembab and slow when replying my tickets

takkkan la lembab nak mampos camni nak reply ticket aku.. memang bengap betol la admin jomhosting ni! aku bukan main reply dalam ticket aku siap tunjuk video Youtube lagi mcm mana aku ping server, diorang balas reply cam sial. mintak aku sendiri plak check version software diorang, mmg takde professionalism langsung.

I replied their ticket on ~10:15am and they replied me back at 4:30pm. That's 5 hours later. Memamng bangsat. If they cannot solve this problem, i definitley will remove my webserver & hosting to different provider. We'll see what will happen.



And the below is the one replied back by jomhosting team after 5 fucking hours.

Wednesday, March 21, 2012

How-to links on Drupal Doc

I find it helpful when Drupal Doc lists down some howto topics. It shows some links on writing own module starting from the beginner level to more complicated areas.

Module HowTos



I'm penniless after spending my last RM50 on Philips headphone & microphone

Just came back from my routine workout today at FF. I was a bit disappointed at the gym because when i put my heart detector strap, it did not work, so the whole running was done without me being able to monitor my actual kcal burn and my heart rate. I hope it is not faulty as i just bought it at the end of last year. it would be shameful if i have to kick that stuff out and crash it.

Anyway, right after finishing my workout, i stopped by at computer centre section 14 because i want to look around on a good quality headphone with attached microphone. I knew that if i were to spend on this thing, it would be on my last RM50. On second thought, as i seldom stop by at that place, i finally grabbed one which i believe is good quality and affordable. the price is RM59, so there was the last RM50 out of my pocket. I definitely will use it to the fullest on my seringgit.com project.

When i reached my office, i brought along the new gadget to my place and straight away plug into my notebook. And as what had happened before, my fucking notebook still showed some intermittent problem. Sometimes it works well with the microphone being jacked into the socket hole and most of the times, it gave me headache. I wish i can crash this notebook into pieces. But after few attempts of plugging in and out of the socket, it detected the microphone. Hmmm.. at least this proved that the new gadget i bought is in good shape.


.

Tuesday, March 20, 2012

How to set a clean URL for my drupalfree.com

My drupalfree.com blog is already up but before i plan to aggressively promote this blog in the internet through google, i must make sure that the URL is clean. Currently it is running with non-clean url. This will not make a good reference for any search engine.



Well, i think for the time being, i'll just populate the blog with as many contents as possible. Just make sure that it will be update regularly so that any search engine out there will capture the link and record it in its ranking.

.