Friday, February 4, 2011

Module Creating In Drupal

At minimal, create 2 kind of files:
1. hello.info
  name = Hello Module   ; this will appear in the module 
                        ; configuration and other display text
  description = A module for displaying text  
  package = My Module   ; categories your module
  core = 7.x

2. hello.module
   <?php
   /**
    * Implements hook_menu()
    *
    * Simply provide a menu entry
    */
   function hello_menu(){
        $item['hello/morning'] = array(
            'title' => 'Hello, Good Morning!',
            'description' => 'Greeting Message',
            'page callback' => 'lol',
            'access callback' => TRUE
         );
         return $item;
    }

     /**
      * Provide simply text greeting message
      */
     function lol(){
        return t('Hello, how are you today? We hope you are all right');
     }

3. You have just finished. Now place the two file in a hello folder, then archive it.
4. Open your Drupal administration page, then install the module. Then enable it
5. See in the navigation menu, and try to click it.

Thursday, February 3, 2011

For Clean URL

For clean url, don't use index function or page. Use index function or index page just for redirecting your web page because the browser cannot actually do the right way for managing the url.

Form Handling In CodeIgniter

<?php

class Blog extends CI_Controller
{
    function index()
    {
        echo "<h1>Entry Your Blog</h1>";
        echo "<form method=\"post\" action=\"blog/insert\">";
        echo "<input type=\"text\" name=\"title\">";
        echo "<textarea name=\"content\"></textarea>";
        echo "<input type=\"submit\" value=\"Save\"/></form>";
    }

    function insert()
    {
        $title = $_POST['title'];
        $content = $_POST['content'];
        $data = array(
            'title'=>$title,
            'content'=>$content
        );
        $this->db->insert('article',$data);
    }
}

$this In CodeIgniter

1. $this->load->view('view_file_name', $array, false);
2. $this->db->query($query);

Active Records

1. To query a table, type:
    $query = $this->db->get('table_name');
    foreach($query->result() as $row)
    {
        echo $row->id;
        echo $row->name;
    }
2.To insert data to a table,use:
    $data = array(
        'id'=>'1',
        'name'=>'lady gaga'
    );
    $this->db->insert('table_name',$data);

Handling Database In CI

To handle database in CodeIgniter by traditional way, 
1. set default setting in application/config/database.php to your database setting
2. set application/config/autoload.php to autoload['libraries'] = array('database');
3.Then do like this below in controller:
    $query = $this->db->query('SELECT * FROM musim');
    foreach($query->result() as $row){
        echo $row->id;     // id in table
        echo $row->name;   // name in table
        echo $row->city;   // city in table
    }
    echo 'Total Rows: '.$query->num_rows();

4. For inserting some data, use
    $query = "INSERT INTO musim VALUES (null,".$musim.")";
    $this->db->query($query);
    echo $this->db->affected_rows();

Wednesday, February 2, 2011

TinyMCE Options

The options syntax is an javascript object literal members. For example
skin: "o2k7"       // This shows that the variable is skin, while the value of the variable is silver.
Here's other options:
theme : "advanced" or "simple"    // this shows how many default toolbar icons.
theme_advanced_toolbar_align : "left", "center" or "right"    // alignment of toolbar if theme is "advanced" set.
theme_advanced_toolbar_location : "bottom" or "top"
theme_advanced_statusbar_location : "top" or "bottom"

buttons - plugins:
save - save
paste - paste


just buttons:
cut - copy - newdocument 
bold - italic - underline - strikethrough 
justifyleft - justifyright - justifycenter - justifyfull
fontselect - fontsizeselect - formatselect - styleselect