Chaitanya Lakshmi
  • About Me
  • Job Duties
  • Knowledge Blog
  • Applications
  • Contact Us
    • Linked In
    • Facebook
  • About Me
  • Job Duties
  • Knowledge Blog
  • Applications
  • Contact Us
    • Linked In
    • Facebook

What are Important Drupal Functions in common.inc?

2/22/2012

0 Comments

 
1. base_path()
Syntax:
base_path()

Description:
Returns the base URL path of the Drupal installation. At the very least, this will always default to.

2. drupal_add_css()
Syntax:
drupal_add_css($path = NULL, $type = 'module', $media = 'all', $preprocess = TRUE)

Description:
Adds a CSS file to the stylesheet queue.

Example:
drupal_add_css(drupal_get_path('module', 'book') .'/book.css');

3. drupal_add_js()
Syntax:
drupal_add_js($data = NULL, $type = 'module', $scope = 'header', $defer = FALSE, $cache = TRUE, $preprocess = TRUE)

Description:
Add a JavaScript file, setting or inline code to the page.

Example:
drupal_add_js(drupal_get_path('module', 'gems_common') . '/common.js');

4. drupal_error_handler()
Syntax:
drupal_error_handler($errno, $message, $filename, $line, $context)

Description:
 Log errors as defined by administrator.

 Error levels:
 - 0 = Log errors to database.
 - 1 = Log errors to database and to screen.

5. drupal_eval()
Syntax:
drupal_eval($code)

Description:
Evaluate a string of PHP code.  A string containing the printed output of the code, followed
by the returned output of the code.

6. drupal_get_breadcrumb()
Syntax:
drupal_get_breadcrumb()

Description:
Get the breadcrumb trail for the current page.

7. drupal_get_content()
Syntax:
drupal_get_content($region = NULL, $delimiter = ' ')

Description:
Get assigned content in all or specific region.

8. drupal_get_html_head()
Syntax:
drupal_get_html_head()

Description:
Retrieve output to be displayed in the head tag of the HTML page.

9. drupal_goto()
Syntax:
drupal_goto($path = '', $query = NULL, $fragment = NULL, $http_response_code = 302)

Description:
Send the user to a different Drupal page.

10. drupal_json()
Syntax:
drupal_json($var = NULL)

Description:
Return data in JSON format.

11. drupal_not_found()
Syntax:
drupal_not_found()

Description:
Generates a 404 error if the request can not be handled.

12. drupal_access_denied()
Syntax:
drupal_access_denied()

Description:
Generates a 403 error if the request is not allowed.

13. drupal_render()
Syntax:
drupal_render(&$elements)


Description:
Renders HTML given a structured array tree.

14. drupal_site_offline()
Syntax:
drupal_site_offline()

Description:
Generates a site off-line message.

15. format_date()
Syntax:
format_date($timestamp, $type = 'medium', $format = '', $timezone = NULL, $langcode = NULL)

Description:
Format a date with the given configured format or a custom format string.

16. l()
Syntax:
4.6 – 5 l($text, $path,
$attributes
= array(), $query = NULL, $fragment = NULL, $absolute = FALSE, $html = FALSE) 6 l($text, $path,
$options
= array()) 7 – 8 l($text, $path, array $options = array())
Description:
Format an internal Drupal link.

Example #1: using Drupal 4-5
l(
  'An <strong>awesome</strong> link!',
  'node/56',
  array('class' => 'widelink'),
  NULL,
  NULL,
  FALSE,
  TRUE);

 
Example #2: using Drupal 6

print l('Privacy Policy', 'privacypolicy', array('attributes' => array('target' => '_blank')));

17. t()
Syntax:
t($string, $args = array(), $langcode = NULL)


Description:
Translate strings to the page language or a given language.

Example:
$output .= '<p>'. t('Go to the <a href="@contact-page">contact page</a>.', array('@contact-page' => url('contact'))) .'</p>';

18. valid_email_address()
Syntax:
valid_email_address($mail)

Description:
Verify the syntax of the given e-mail address.

Return:  TRUE if the address is in a valid format.

19. valid_url()
Syntax:
valid_url($url, $absolute = FALSE)

Description:
Verify the syntax of the given URL.

Return: TRUE if the URL is in a valid format.
0 Comments



Leave a Reply.

    Archives

    April 2012
    March 2012
    February 2012

    Categor

    All
    Ajax
    Api
    Cross Site Scripting
    Css
    Curl
    Design Patterns
    Drupal
    Exception Handling
    Htaccess
    Html
    Javascript
    Jquery
    Json
    Linux
    Mysql
    Oops
    Php
    Regular Expressions
    Web 2.0
    Webservices
    Wordpress
    Xhtml

    RSS Feed

Powered by Create your own unique website with customizable templates.