$child_tid = 1075;
$parents = taxonomy_get_parents($child_tid); foreach ($parents as $ksubspec) { $parents_lists .= $ksubspec->name." | "; } echo "Parent Taxonomy list : ".$parents_lists;
0 Comments
$parent_tid = 1002;
$childs = taxonomy_get_children($parent_tid); foreach ($childs as $ksubspec) { $childs_lists .= $ksubspec->name." | "; } echo "Child Taxonomy list : ".$childs_lists; /* Assigning a PHP code into a variable or
We can load PHP code based block content into a variable */ $phpContent = ' <?php $sampleString = "my sample content!"; echo "Length of <i>" . $sampleString . "</i> is : " . strlen($sampleString); ?>'; /* PHP code is processed and giving output */ echo drupal_eval($phpContent); Output: Length of my sample content! is : 18 drupal_set_title (path.inc)
drupal_set_title($title = NULL)Set the title of the current page, for display on the page and in the title bar. Parameters: $title Optional string value to assign to the page title; or if set to NULL (default), leaves the current title unchanged. Return value The updated title of the current page. Beware: $title is interpreted as HTML. If you have plaintext strings such as for example $node->title, you must escape them with check_plain or use the correct placeholder in t() before passing them to drupal_set_title(). If you don't, users can execute a cross site scripting attack against your site. // Incorrect: drupal_set_title($node->title); drupal_set_title(t('Foo !title', array('!title' => $node->title))); // Correct: drupal_set_title(check_plain($node->title)); drupal_set_title(t('Foo @title', array('@title' => $node->title))); $content
Node content, teaser if it is a summary. $date Formatted creation date. $directory The directory the theme is located in, e.g. themes/garland. $id The sequential ID of the node being displayed in a list. $is_front True if the front page is currently being displayed. $links Node links. $name Formatted name of author. $node (object) The node object. $node_url Link to node. $page True if the node is being displayed by itself as a page. $picture HTML for user picture, if enabled. $sticky True if the node is sticky. $submitted Author and create date, if the node info display is enabled for this node type. $taxonomy (array) array of HTML links for taxonomy terms. $teaser Only returns the teaser rather than the full node text. $terms HTML for taxonomy terms. $title Title of node. $zebra Alternates between odd/even in a list. 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. function my_module_my_form($form_state) {
$form['name'] = array( '#type' => 'fieldset', '#title' => t('Name'), '#collapsible' => TRUE, '#collapsed' => FALSE, ); // Removes the #required property and // uses the validation function instead. $form['name']['first'] = array( '#type' => 'textfield', '#title' => t('First name'), '#default_value' => "First name", '#description' => "Please enter your first name.", '#size' => 20, '#maxlength' => 20, ); $form['submit'] = array( '#type' => 'submit', '#value' => 'Submit', ); // Adds a new button to clear the form. The #validate property // directs the form to use a new validation handler function in place // of the default. $form['clear'] = array( '#type' => 'submit', '#value' => 'Reset form', '#validate' => array('my_module_my_form_clear'), ); return $form; } // This is the new validation handler for our Reset button. Setting // the $form_state['rebuild'] value to TRUE, clears the form and also // skips the submit handler.function my_module_my_form_clear($form, &$form_state) { $form_state['rebuild'] = TRUE; } |