Helpers (base) Functions

Last modified: August 28, 2008 - 18:45

Functions

test_empty_string($string, $test = '')

Test if a string is empty, or equals another string. If so, return a themed empty placeholder. Else return the input string.

  • Calling parameters
  • $string
    The string we want to test to find out if it's empty;
    $test
    Optional string to test against; this is in case you want to redefine "empty."
  • Return
  • themed empty placeholder or the input string

format_shorten_string($string, $length = 15, $count_addition = 3)

Formats a chopped off string of a certain length. Calls a theme function to do the actual formatting. By default it will return strings in the form of "verylongstringwithsomecoo..."

  • Calling parameters
  • $string
    the original string.
    $count_addition
    Optional, provides an amount for the additional characters. Giving this parameter, for example a value of 5, you will receive a shortened string in the form of "verylongstringwithsomec....."
  • Return
  • the shortened string

drupal_parse_html($tags)

Function to parse tags (HTML) string into an array suitable for drupal_attributes. Core patch pending at ?

  • Calling parameters
  • $tags
    string containing HTML to be parsed.
  • Return
  • array with attribute as key and value as value.

void_page()

Render nothing - a blank page.

Menu items
helpers/void
  • Calling parameters
  • None
  • Return
  • Blank page.

get_block($name, $delta = 0)

Get a block as object prepared to use in the theme_block function.

  • $name the modulename (block name) to get the block from.
  • $delta the block delta. Each block in each module has a unique delta value. A number indicating that block.
    • Calling parameters
    • $name
      the name of the module providing the block.
      $delta
      the block delta. Each block in each module has a unique delta value, which is (usually) a number indicating the block.
    • Return
    • An object containing the information about the block.

    user_has_role($user, $roles)

    Find out if a user has a certain role or roles. This is not the same as "user_access."

    • Calling parameters
    • $user
      a user object, which must contain the $user->roles array such as would be provided from "user_load."
      $roles
      an array of roles to check for.
    • Return
    • TRUE
      if the user has a role you checked for.
      FALSE
      if the user is not within any of the requested roles.

    pluralize_en($word)

    Pluralizes English nouns. Note that this uses a set of rules that (while they work well) will not work perfectly on all words.

    • Calling parameters
    • $word
      English noun to pluralize.
    • Return
    • Plural noun.

    singularize_en($word)

    Singularizes English nouns. Note that this uses a set of rules that (while they work well) will not work perfectly on all words.

    • Calling parameters
    • $word
      English noun to singularize.
    • Return
    • Singular noun.

    Theme Functions

    theme_empty_placeholder($message = NULL)

    Theme an "empty" placeholder.

    • Calling parameters
    • $message
      Optional. Provide a translated message string.
    • Return
    • a string that can be used as placeholder for non existing content. Defaults to a translated "not available."

    theme_read_more($path, $title = NULL)

    Function to consistently theme "read more" links. Core patch pending at http://drupal.org/node/69571

    • Calling parameters
    • $path
      a drupal path or full url to the full resource. Include http:// if you link to external resource.
      $title
      an optional title that will provide a tooltip text when hovering over the link.
    • Return
    • An HTML string to display as the "read more" link.

    theme_definition_list($items = array(), $title = NULL, $filter = TRUE)

    Return a themed list of definition items. Core patch pending at http://drupal.org/node/54898

    • Calling parameters
    • $items
      An array of items to be displayed in the list.
    • The argument is: array("term" => $term, "definitions" => $definitions)
    • If you provide the $definition as arrays, you will get multiple DDs with each DT.
    • If you provide the $definitions as a string, only one DD will be added to the DT.
    • $title
      The title of the list.
      $filter
      Boolean value to define whether or not you wish to filter the input. Should be left TRUE, unless you sanitize the input yourself.
    • Return
    • An HTML string containing the list output.

    theme_name_and_value_pair($name, $value, $filter = TRUE)

    Return a themed name and value as a DT DD pair.

    • Calling parameters
    • $name
      The name string.
      $value
      The value string.
      $filter
      Bool passed on to definition list.
    • Return
    • An HTML string containing the formatted pair.

    theme_none_option($string = NULL)

    Returns a themed "none" string, for usage in a select form. This is in case you wish a general or consistent way of building the <none> strings.

    • Calling parameters
    • $string
      optionally provide a string that goes in the place of the word "none". If you provide this, it will not be translated.
    • Return
    • Themed "none" string ready to be inserted within a select list.

    theme_shorten_string($short_string, $full_string, $count_addition = 3)

    Function to theme the a shortened string (see "shorten_string" above).

    • Calling parameters
    • $short_string
      The shortened string
      $full_string
      The unshortened string, for display in the tooltip
      $count_addition
      Optional. The number of fill characters that the calling function wants to be added. Defaults to three (3).
    • Return
    • HTML string containing the themed string.
  •  
     

    Drupal is a registered trademark of Dries Buytaert.