Group icon
A group for those interested in plugin development

Pages home > Handy helper functions

Handy helper functions

Input and output

  • get_input($name) - Grabs information from a form field (or any variable passed using GET or POST). Also sanitises input, stripping Javascript etc.
  • set_input($name, $value) - Forces a value to a particular variable for subsequent retrieval by get_input().

Entity methods

  • $entity->getURL() - Returns the URL of any entity in the system.
  • $entity->getGUID() - Returns the GUID of any entity in the system.
  • $entity->canEdit() - Returns whether or not the current user can edit the entity.
  • $entity->getOwnerEntity() - Returns the ElggUser owner of a particular entity.

Entity and context retrieval

  • get_user($user_guid) - Given a GUID, returns a full ElggUser entity.
  • page_owner() - Returns the GUID of the current page owner, if there is one.
  • page_owner_entity() - As page_owner() but returns the full entity.
  • get_context() - Returns the current page's context - eg "blog" for the blog plugin, etc. Returns "main" as default.
  • set_context($context) - Forces the context to be a particular thing.
  • elgg_count_comments(entity) - Count the comments on a particular entity.

Interface and annotations

  • elgg_view_listing($icon, $info) - Return the result in a formatted list.
  • elgg_view_comments($entity) - Returns any comments associated with the given entity, as well as
  • friendly_time($unix_timestamp) - Returns a date formatted in a friendlier way - "18 minutes ago", "2 days ago", etc.
  • parse_urls($string) - Converts any URLs in the given string to clickable links.

, , , , , , , , , , , , ,

Last updated 533 days ago by Dave

that's great!

syd died 506 days ago