Saturday, May 28, 2011

Basic PHP knowledge for Drupal - Part 4




4. Arrays: PHP arrays are widely used in drupal for internal coding. Drupal API has enough application of php arrays so one have to understand php array operations for drupal development. Arrays are defined as a variable which holds multiple similar types of data , i.e strings, integers etc. The syntax for php array are listed below,


Syntax:
$a = array('cat','dog','cow'); // String type array
$b = array(1,2,35,6,7); // Integer type array

Arrays can hold any number of elements and php have multiple array functions to perform several operations over them. Please refer to the http://www.php.net for array reference.

See this video for more details about PHP arrays.

Rajinikanth voice before leaving Singapore


Rajinikanth


Actor Rajnikanth has expressed confidence that he would return back fit and fine from Singapore. A voice of the Super Star was released by his daughter Soundarya that has given hope to millions of Rajnikanth fans across the globe.

 
In the audio, Rajnikanth says  ''I thank all my fans who have prayed for my good health. I am amazed at their love and care for me though I am an actor who is paid to act'.
 
He added, ' I will come back with vigour strong, fit and fine with my head high'.

Meanwhile, Rajnikanth left by a Singapore airlines flight accompanied by his wife and two daughters. He would be treated at National Kidney Centre by doctors.
 
The release of audio tape has now given relief to his fans.

Friday, May 27, 2011

Basic PHP knowledge for Drupal - Part 3






2. Functions in PHP: Functions are a block of code where operations and functionalities are defined in one place and called from another place. Thus one can perform a task without writing the same code again. Every function returns a value, it may be an integer, string or boolean etc. Functions must be defined in the included files or scripts to use them. Here goes an example of simple functions which takes 3 numbers, first two numbers are added and then multiplied with the third number.

Function definition:
function foo($a,$b,$c){
$result = ($a+$b) * $c;
return $result;
}

Here $a,$b,$c are called argument signatures. they are just the replica of the parameter which is put as the argument during function call. Functions can be called by value or called by reference. In case of call by reference, function does not need to return anything as in this case modification occurs inside the passed variables (argument).




Function Usage:
echo foo(1,2,3);


The output would be 9.


echo foo(3,2,3);
The output would be 15.


Though there are lot of functions and more complex in nature defined in Drupal API. Don't worry, you don't have to remember all the function names. By doing drupal projects you will automatically remember those useful function names. For other unknown functions, just go to api.drupal.org to get the documentation of all the defined function in Drupal API.

For more reference about PHP functions read this link.

Thursday, May 26, 2011

Basic PHP knowledge for Drupal - Part 2



As per the previous section, five key part of PHP knowledge os necessary to start drupal development.

1. PHP variables: These are represented as $variablename , Also there are certain conventions about variable names like you cannot put "-" in it or you cannot start  with a number like $34abc etc.
Allowable syntaxes are: $var, $var123, $var_12, $var_abc etc. Generally variables are written in lower cases, in certain cases they can be written in Camel Cased ($VarName etc). It is good to practice meaningful variable names while writing code as it prevents confusion among the different programmers.

These variables hold the value required for the programming during php execution. There are also centain types of variable depending upon the content of the variable.

Integer type variable: $var = 1;
Float type variable: $var = 2.33;
String type variable: $var = 'Hello World';
Boolean type variable: $var = true;

These are the four major variable types used widely in drupal coding. You can also assign one variable's value to another variable.

e.g $var1 is a Integer type variable.


$var1 = 5;
$var2 = $var1;

Here $var2 will get the value of $var1 which is 5.

The most exciting feature of PHP variable is automatic type casting. Data types can be converted into any types without type casting.
e.g.
$var1 = "5";
$var2 = 5;

These two variables will be treated as same while code execution, though one is integer and another is string.

In the next chapter I will be telling about functions and their usages.

Wednesday, May 25, 2011

Basic PHP knowledge for Drupal


Drupal is build up on PHP script. hence it is necessary to understand some basic PHP syntax to start with drupal. Though PHP has a large domain and obviously it is quite hard to cover it in a sinble blog post. So I am mentioning some essential parts of PHP that is required for a basic drupal development. If you are non-developer, this will help you to understand drupal well.

The 5 topics are required to understand in PHP for drupal as they are used elsewhere in drupal codebase. They are as follows.

1. PHP Variables
2. Condition and Loops
3. Functions
4. Arrays
5. Class and Object concept.

Generally PHP scripts has an extention .php, however in drupal codes can be written using any extensions like .module, .inc etc. But scripting inside these files follows the php syntax and its rules. PHP script starts with  tag but usually does not require to end with a ?> . The reason behind this is in any open source package (Drupal, Joomla etc.) in PHP, there are lots of files which are included in execution time. As PHP is an interpreted language, PHP parser processes the internal script between  and ?> If accidentally any html markup appears between two subsequent  tags, PHP parser also processes them. This slows down the execution speed and also there is a chance to get unnecessary whitespaces and characters in the output. So ?> tag is not required for any scripting page in drupal. That ensures that only pure php script is processed by PHP parser, not HTML markup.

Each php statement ends with ";" make sure to give this after every statement in the code.

In the next post I will discuss about the upper-mentioned five topics in details so that you can get an idea about PHP scripting methods and its syntaxes to start up drupal development.

Monday, May 23, 2011

How to print comment anywhere in Drupal


Drupals standard practice of printing node comments below the node can get a bit stale. Sometimes you may want, or simply need to, print them somewhere else. Wouldn’t be great if comments and the comment form were just variables you could move around?

Well you can—thanks to Drupal 6’s phptemplate_preprocess_page function we can easily store both the comments and the comment form in variables. The only caveat is that you must set the comment reply form to a separate page first, or something might break.

The following snippets store the comment form and comments in variables and allow you print them in page.tpl.php.


// Store comments and the comment form in variablesfunction phptemplate_preprocess_page(&$vars) {
  $vars['comments'] = $vars['comment_form'] = '';
  if (module_exists('comment') && isset($vars['node'])) {
    $vars['comments'] = comment_render($vars['node']);
    $vars['comment_form'] = drupal_get_form('comment_form',
    array('nid' => $vars['node']->nid));
}
}

// Unset comments from nodefunction phptemplate_preprocess_node(&$vars) {
$vars['node']->comment = 0;
}
?>


Now you can print $comments and $comment_form anywhere in page.tpl.php, and they will only print when you are viewing a node.

Sunday, May 15, 2011

SET EXAMS TO BE HALD ON AUGUST 14



COIMBATORE:  The State Eligibility Test (SET) for aspiring college teachers will be held on August 14 at 50 centres in 10 places, Vice-Chancellor of Bharathiar University C. Swaminathan told a press conference here on Wednesday. Candidates who had completed their post graduation with 55 per cent marks are eligible to apply for the examination, which offers a choice of 27 subjects. It will be held in Chennai, Coimbatore, Madurai, Tiruchi, Salem, Tirunelveli, Chidambaram, Karaikudi, Vellore, and Puducherry. There were three papers, two with objective type questions and one in the descriptive mode. Those who cleared the first two only were eligible to sit for the third examinations, the Vice-Chancellor said.
The university was at present permitted to conduct only one examination a year. Mr. Swaminathan said there were talks to allow the university to hold two examinations in a year because of the large number of faculty vacancies.
Applications will be available from May 14 till June 14. They can be downloaded from the university’s website www.b-u.ac.in. or the website of UGC.

Vadivelu Before & After Election 2011 COMEDY



Vadivelu Before & After Election 2011 COMEDY




Saturday, May 14, 2011

அமீரின் இயக்கத்தில் விஜய் நடிக்கும் கண்ணபிரான்


 "ஆதி பகவான்" படத்தை தொடர்ந்து டைரக்டர் அமீர் அடுத்து விஜய்யை வைத்து "கண்ணபிரான்" என்ற படத்தை இயக்க போகிறாராம். 

"ராம்", "மெளம் ‌பேசியதே", "பருத்திவீரன்" போன்ற சூப்பர்ஹிட் படங்களை இயக்கிய டைரக்டர் அமீர், தற்போது "ஜெயம்" ரவியை வைத்து "ஆதி பகவான்" என்ற படத்தை இயக்கி வருகிறார்.

"எங்கேயும் காதல்" படத்தை தொடர்ந்து ஜெயம் ரவி நடித்து வரும் இந்தபடத்தில் மிகவும் வித்யாசமான கேரக்டரில் நடித்து வருகிறாராம். 

இந்தபடத்தை முடித்த பின்னர் அமீர், அடுத்து "கண்ணபிரான்" என்ற படத்தை இயக்க இருக்கிறர்.

அதிலும் இப்படத்தின் நாயகனாக நமது இளைய தளபதி விஜய் நடிக்க இருக்கிறார் என்ற தகவல் வெளியாகியுள்ளது. இதுகுறித்த அறிவிப்பு விரைவில் வெளியாகும் எனத் தெரிகிறது.

திமுக அதிர்ச்சி தோல்வி ! வடிவேலுவின் அடுத்த கட்ட நகர்வு - மாப்புக்கு வெச்சிட்டாங்களே ஆப்பு!


சட்டசபை தேர்தலில் திமுக தோல்வி அடைந்ததைத் தொடர்ந்து நடிகர் வடிவேலு அதிர்ச்சி அடைந்துள்ளார். அடுத்து என்ன செய்வதென்று தெரியாமல் விழித்துக் கொண்டிருக்கும் அவரது வீட்டுக்கு போலீஸ் பாதுகாப்பு போடப்பட்டுள்ளது. 

சட்டசபை தேர்தல் பிரசாரத்தில் திமுக கூட்டணிக்கு ஆதரவாக பிரசாரத்தில் ஈடுபட்ட வடிவேலு, தேமுதிக தலைவர் விஜயகாந்தை குடிகாரன் என்று பேசி கடுமையாக தாக்கினார். 

இந்த குசும்பு இணையத்தில் வடிவேலுவின் அரசியல் அனல் பறக்கும் பேச்சுக்களை வாசகர்கள் வாசித்து நொந்து நூடில்ஸ் ஆன கதை நினைவிருக்கலாம் .... (அது போன மாசம்) வடிவேலுவின் காமெடியான பேச்சை கேட்க ஆயிரக்கணக்கான ரசிகர்கள் திரண்டனர்.

வந்தவர்கள் எல்லாம் திமுக கூட்டணிக்குத்தான் ஓட்டு போடுவார்கள் என்று நினைத்த வடிவேலு, தனது பேச்சில் மேலும் மேலும் கேவலமான வார்த்தைகளை பயன்படுத்தத் தொடங்கினார்.

தேர்தல் பிரசாரத்தை முடித்த பின்னர் அளித்த பேட்டியில் கூட, செல்லும் இடங்களில் எல்லாம் மக்கள் வரவேற்பு அதிக அளவில் இருந்ததாகவும், திமுக மாபெரும் வெற்றி பெறும் என்றும் கூறினார்.

இப்போது திமுக அதிர்ச்சி தோல்வியை சந்தித்துள்ளது. இது யாரை பாதிக்கிறதோ இல்லையோ... வடிவேலுவை நிச்சயம் பாதிக்கும் என்கிறார்கள் கோடம்பாக்கத்து முக்கிய புள்ளிகள். 

சக நடிகர் என்று கூட பாராமல் ஏக வசனத்தில் பேசி விஜயகாந்தை விமர்சித்ததால் சில சினிமா வாய்ப்புகளை இழந்திருக்கும் வடிவேலுவின் கதி இனி என்னாக இருக்கும்? என்ற கேள்விக்குறி எழுந்துள்ளது. 

தேர்தல் முடிவைத் தொடர்ந்து வடிவேலுவின் அடுத்த ஸ்டெப் என்னவாக இருக்கும்? என்ற ‌கேள்வி எழுந்துள்ள நிலையில் இருவேறு விதமாக பேசப்பட்டு வருகிறது.

ஒன்று போயஸ் கார்டன் சென்று சமாதானம் ஆவது; இன்னொன்று திமுகவிலேயே ஐக்கியமாவது. இந்த இரண்டில் ஒரு முடிவைத்தான் வடிவேலு எடுக்கக் கூடும் என கோடம்பாக்கத்தில் பேச்சு எழுந்துள்ளது. 

இதற்கிடையில் மதுரையில் மத்திய அமைச்சர் அழகிரியின் வீட்டுக்கு சென்ற வடிவேலு, அழகிரியுடன் சிறிது நேரம் பேசினார். பின்னர் அங்கிருந்து புறப்பட்டுச் சென்றார். 

அவர் எங்கு இருக்கிறார் என்பது தெரியவில்லை. அதேநேரம் வடிவேலுவின் வீட்டுக்கு விஜயகாந்த் ரசிகர்களால் தாக்கப்படும் வாய்ப்பு உள்ளது என்பதால் சென்னை மற்றும் மதுரையில் உள்ள அவரது வீட்டுக்கு பலத்த போலீஸ் பாதுகாப்பு போடப்பட்டுள்ளது.

Friday, May 13, 2011

நான் ஆசைப்பட்டது நடந்துவிட்டது : விஜய் பரபரப்பு பேட்டி


நடந்து முடிந்த தமிழக சட்டசபை தேர்தல் முடிவுகள் வெளியாகியுள்ளன. இதில் அதிமுக கூட்டணி அமோக வெற்றி பெற்றுள்ளது. 

இதையடுத்து நடிகர் விஜய் அதிமுக பொதுச்செயலாளர் ஜெயலலிதாவை போயஸ்கார்டனில் சந்தித்து பூங்கொத்து கொடுத்து வாழ்த்தினார். 

பின்னர் செய்தியாளர்களிடம் பேசிய அவர், நான் தேர்தலுக்கு முன்பே ஆட்சி மாற்றம் வேண்டும் என்று கூறிவந்தேன். ஆட்சி மாற்றம் வேண்டும் என்பதற்காக என் தந்தை அதிமுகவுக்கு ஆதரவாக தீவிர பிரச்சாரம் செய்தார். 

வாக்குப்பதிவு அன்று ஓட்டு போட்டுவிட்டு வெளியே வந்ததும், மக்கள் ஆட்சி மாற்றத்தை விரும்புகிறார்கள். அவர்கள் ஆசை நிறைவேற வேண்டும் என்று விரும்புகிறேன் என பேட்டி அளித்தேன். என் ஆசையும் ஆட்சி மாற்றம் வேண்டும் என்பதுதான். நான் ஆசைப்பட்டது நடந்துவிட்டது


Friday, May 6, 2011

Interacting via the Command-Line



Interacting via the Command-Line

Besides command-line input, another way to provide input to a program is via the Console. Typically, it works like this: You prompt the user for some input, they type something in and press the Enter key, and you read their input and take some action. Listing 1-3 shows how to obtain interactive input from the user.
Listing 1-3. Getting Interactive Input: InteractiveWelcome.cs
// Namespace Declarationusing System; // Program start classclass InteractiveWelcome {     // Main begins program execution.    public static void Main()     {         // Write to console/get input        Console.Write("What is your name?: ");         Console.Write("Hello, {0}! ", Console.ReadLine());         Console.WriteLine("Welcome to the Mahe's Home page!");     } }
In Listing 1-3, the Main method doesn't have any parameters -- mostly because it isn't necessary this time. Notice also that I prefixed the Main method declaration with the publickeyword. The public keyword means that any class outside of this one can access that class member. For Main, it doesn't matter because your code would never call Main, but as you go through this tutorial, you'll see how you can create classes with members that must be public so they can be used. The default access is private, which means that only members inside of the same class can access it. Keywords such as public and private are referred to as access modifiers. Lesson 19 discusses access modifiers in more depth.
There are three statements inside of Main and the first two are different from the third. They are Console.Write(...) instead of Console.WriteLine(...). The difference is that theConsole.Write(...) statement writes to the console and stops on the same line, but the Console.WriteLine(...) goes to the next line after writing to the console.
The first statement simply writes "What is your name?: " to the console.
The second statement doesn't write anything until its arguments are properly evaluated. The first argument after the formatted string is Console.ReadLine().  This causes the program to wait for user input at the console. After the user types input, their name in this case, they must press the Enter key. The return value from this method replaces the "{0}" parameter of the formatted string and is written to the console. This line could have also been written like this:
string name = Console.ReadLine();
Console.Write("Hello, {0}! ", name);

The last statement writes to the console as described earlier. Upon execution of the command-line with "InteractiveWelcome", the output will be as follows:
>What is your Name?  [Enter Key] >Hello, !  Welcome to the C# Mahe !

Thursday, May 5, 2011

Getting Started with C#


This lesson will get you started with C# by introducing a few very simple programs. Here are the objectives of this lesson:




  • Understand the basic structure of a C# program.
  • Obtain a basic familiarization of what a "Namespace" is.
  • Obtain a basic understanding of what a Class is.
  • Learn what a Main method does.
  • Learn how to obtain command-line input.
  • Learn about console input/output (I/O).
A Simple C# Program
There are basic elements that all C# executable programs have and that's what we'll concentrate on for this first lesson, starting off with a simple C# program. After reviewing the code in Listing 1-1, I'll explain the basic concepts that will follow for all C# programs we will write throughout this tutorial. Please see Listing 1-1 to view this first program.
Warning: C# is case-sensitive.

Listing 1-1. A Simple Welcome Program: Welcome.cs
// Namespace Declaration
using
 System;

// Program start class
class WelcomeCSS
{    // Main begins program execution.    static void Main()
    {        // Write to console        Console.WriteLine("Welcome to the C# Station Tutorial!");
    }
}
The program in Listing 1-1 has 4 primary elements, a namespace declaration, a class, a Main method, and a program statement. It can be compiled with the following command line:
csc.exe Welcome.cs
This produces a file named Welcome.exe, which can then be executed. Other programs can be compiled similarly by substituting their file name instead of Welcome.cs. For more help about command line options, type "csc -help" on the command line. The file name and the class name can be totally different.
Note for VS.NET Users: The screen will run and close quickly when launching this program from Visual Studio .NET. To prevent this, add the following code as the last line in the Main method:
// keep screen from going away
// when run from VS.NET

Console.ReadLine();