Elgg  Version 3.0
Namespaces | Functions
views.php File Reference

Go to the source code of this file.

Namespaces

 Elgg\Core
 Updates the advanced settings for the primary site object.
 

Functions

 elgg_set_viewtype ($viewtype= '')
 Manually set the viewtype. More...
 
 elgg_get_viewtype ()
 Return the current view type. More...
 
 _elgg_is_valid_viewtype ($viewtype)
 Checks if $viewtype is a string suitable for use as a viewtype name. More...
 
 elgg_register_viewtype_fallback ($viewtype)
 Register a viewtype to fall back to a default view if a view isn't found for that viewtype. More...
 
 elgg_does_viewtype_fallback ($viewtype)
 Checks if a viewtype falls back to default. More...
 
 elgg_register_ajax_view ($view)
 Register a view to be available for ajax calls. More...
 
 elgg_unregister_ajax_view ($view)
 Unregister a view for ajax calls. More...
 
 elgg_register_external_view ($view, $cacheable=false)
 Registers a view as being available externally (i.e. More...
 
 elgg_unregister_external_view ($view)
 Unregister a view for ajax calls. More...
 
 elgg_set_view_location ($view, $location, $viewtype= '')
 Set an alternative base location for a view. More...
 
 elgg_view_exists ($view, $viewtype= '', $recurse=true)
 Returns whether the specified view exists. More...
 
 elgg_list_views ($viewtype= 'default')
 List all views in a viewtype. More...
 
 elgg_view ($view, $vars=[], $viewtype= '')
 Return a parsed view. More...
 
 elgg_view_deprecated ($view, array $vars, $suggestion, $version)
 Display a view with a deprecation notice. More...
 
 elgg_extend_view ($view, $view_extension, $priority=501)
 Extends a view with another view. More...
 
 elgg_unextend_view ($view, $view_extension)
 Unextends a view. More...
 
 elgg_get_view_extensions ($view)
 Get the views (and priorities) that extend a view. More...
 
 elgg_prepend_css_urls ($css, $path)
 In CSS content, prepend a path to relative URLs. More...
 
 elgg_view_page ($title, $body, $page_shell= 'default', $vars=[])
 Assembles and outputs a full page. More...
 
 elgg_view_resource ($name, array $vars=[])
 Render a resource view. More...
 
 _elgg_views_prepare_head ($title)
 Prepare the variables for the html head. More...
 
 _elgg_views_prepare_favicon_links ($hook, $type, $head_params, $params)
 Add favicon link tags to HTML head. More...
 
 elgg_view_layout ($layout_name, $vars=[])
 Displays a layout with optional parameters. More...
 
 _elgg_normalize_content_layout_vars (array $vars=[])
 Normalizes deprecated content layout $vars for use in default layout Helper function to assist plugins transitioning to 3.0. More...
 
 elgg_view_menu ($menu, array $vars=[])
 Render a menu. More...
 
 elgg_view_menu_item (\ElggMenuItem $item, array $vars=[])
 Render a menu item (usually as a link) More...
 
 elgg_view_entity (\ElggEntity $entity, array $vars=[])
 Returns a string of a rendered entity. More...
 
 elgg_view_entity_icon (\ElggEntity $entity, $size= 'medium', $vars=[])
 View the icon of an entity. More...
 
 elgg_view_annotation (\ElggAnnotation $annotation, array $vars=[])
 Returns a string of a rendered annotation. More...
 
 elgg_view_entity_list ($entities, array $vars=[])
 Returns a rendered list of entities with pagination. More...
 
 elgg_view_annotation_list ($annotations, array $vars=[])
 Returns a rendered list of annotations, plus pagination. More...
 
 elgg_view_entity_annotations (\ElggEntity $entity, $full_view=true)
 Display a plugin-specified rendered list of annotations for an entity. More...
 
 elgg_view_title ($title, array $vars=[])
 Renders a title. More...
 
 elgg_view_friendly_time ($time)
 Displays a UNIX timestamp in a friendly way. More...
 
 elgg_view_comments ($entity, $add_comment=true, array $vars=[])
 Returns rendered comments and a comment form for an entity. More...
 
 elgg_view_image_block ($image, $body, $vars=[])
 Wrapper function for the image block display pattern. More...
 
 elgg_view_module ($type, $title, $body, array $vars=[])
 Wrapper function for the module display pattern. More...
 
 elgg_view_message ($type, $body, array $vars=[])
 Wrapper function for the message display pattern. More...
 
 elgg_view_river_item ($item, array $vars=[])
 Renders a human-readable representation of a river item. More...
 
 elgg_view_form ($action, $form_vars=[], $body_vars=[])
 
 elgg_set_form_footer ($footer= '')
 Sets form footer and defers its rendering until the form view and extensions have been rendered. More...
 
 elgg_get_form_footer ()
 Returns currently set footer, or false if not in the form rendering stack. More...
 
 _elgg_split_vars (array $vars=[], array $prefixes=null)
 Split array of vars into subarrays based on property prefixes. More...
 
 elgg_view_field (array $params=[])
 Renders a form field, usually with a wrapper element, a label, help text, etc. More...
 
 elgg_view_tagcloud (array $options=[])
 Create a tagcloud for viewing. More...
 
 elgg_view_list_item ($item, array $vars=[])
 View an item in a list. More...
 
 elgg_view_icon ($name, $vars=[])
 View an icon glyph. More...
 
 elgg_register_rss_link ()
 Include the RSS icon link and link element in the head. More...
 
 elgg_unregister_rss_link ()
 Remove the RSS icon link and link element from the head. More...
 
 _elgg_has_rss_link ()
 Should the RSS view of this URL be linked to? More...
 
 autoregister_views ($view_base, $folder, $ignored, $viewtype)
 Auto-registers views from a location. More...
 
 _elgg_views_minify ($hook, $type, $content, $params)
 Minifies simplecache CSS and JS views by handling the "simplecache:generate" hook. More...
 
 _elgg_views_preprocess_css ($hook, $type, $content, $params)
 Preprocesses CSS views sent by /cache URLs. More...
 
 _elgg_views_amd ($hook, $type, $content, $params)
 Inserts module names into anonymous modules by handling the "simplecache:generate" and "cache:generate" hook. More...
 
 _elgg_views_send_header_x_frame_options ()
 Sends X-Frame-Options header on page requests. More...
 
 _elgg_view_may_be_altered ($view, $path)
 Is there a chance a plugin is altering this view? More...
 
 elgg_views_boot ()
 Initialize viewtypes on system boot event This ensures simplecache is cleared during upgrades. More...
 
 _elgg_get_js_site_data ()
 Get the site data to be merged into "elgg" in elgg.js. More...
 
 _elgg_get_js_page_data ()
 Get the initial contents of "elgg" client side. More...
 
 _elgg_view_under_viewtype ($view, $vars, $viewtype)
 Render a view while the global viewtype is temporarily changed. More...
 
 _elgg_set_lightbox_config ($hook, $type, $return, $params)
 Set lightbox config. More...
 
 _elgg_views_file_help_upload_limit (\Elgg\Hook $hook)
 Add a help text to input/file about upload limit. More...
 
 _elgg_map_icon_glyph_class (array $classes, $map_sprites=true)
 Maps legacy sprite classes and FontAwesome 4 classes to FontAwesome 5 classes. More...
 

Function Documentation

_elgg_get_js_page_data ( )

Get the initial contents of "elgg" client side.

Will be extended by elgg.js.

Returns
array
Examples:
/root/Elgg/engine/lib/views.php.

Definition at line 1869 of file views.php.

_elgg_get_js_site_data ( )

Get the site data to be merged into "elgg" in elgg.js.

Unlike _elgg_get_js_page_data(), the keys returned are literal expressions.

Returns
array
Examples:
/root/Elgg/engine/lib/views.php.

Definition at line 1845 of file views.php.

_elgg_has_rss_link ( )

Should the RSS view of this URL be linked to?

Returns
bool
Examples:
/root/Elgg/engine/lib/views.php.

Definition at line 1594 of file views.php.

_elgg_is_valid_viewtype (   $viewtype)

Checks if $viewtype is a string suitable for use as a viewtype name.

Parameters
string$viewtypePotential viewtype name. Alphanumeric chars plus _ allowed.
Returns
bool
Examples:
/root/Elgg/engine/lib/views.php.

Definition at line 91 of file views.php.

_elgg_map_icon_glyph_class ( array  $classes,
  $map_sprites = true 
)

Maps legacy sprite classes and FontAwesome 4 classes to FontAwesome 5 classes.

Parameters
array$classesIcon classes
bool$map_spritesMap legacy Elgg sprites
Returns
array
Examples:
/root/Elgg/engine/lib/views.php.

Definition at line 2015 of file views.php.

_elgg_normalize_content_layout_vars ( array  $vars = [])

Normalizes deprecated content layout $vars for use in default layout Helper function to assist plugins transitioning to 3.0.

Parameters
array$varsVars
Returns
array
Examples:
/root/Elgg/engine/lib/views.php.

Definition at line 676 of file views.php.

_elgg_set_lightbox_config (   $hook,
  $type,
  $return,
  $params 
)

Set lightbox config.

Parameters
string$hook"elgg.data"
string$type"site"
array$returnData
array$paramsHook params
Returns
array
Examples:
/root/Elgg/engine/lib/views.php.

Definition at line 1952 of file views.php.

_elgg_split_vars ( array  $vars = [],
array  $prefixes = null 
)

Split array of vars into subarrays based on property prefixes.

See also
elgg_view_field()
Parameters
array$varsVars to split
array$prefixesPrefixes to split
Returns
array
Examples:
/root/Elgg/engine/lib/views.php.

Definition at line 1353 of file views.php.

_elgg_view_may_be_altered (   $view,
  $path 
)

Is there a chance a plugin is altering this view?

Note
Must be called after the [init, system] event, ideally as late as possible.
Always returns true if the view's location is set in /engine/views.php. Elgg does not keep track of the defaults for those locations.

// check a view in core if (_elgg_view_may_be_altered('foo/bar', 'foo/bar.php')) { // use the view for BC }

// check a view in a bundled plugin $dir = DIR . "/views/" . elgg_get_viewtype(); if (_elgg_view_may_be_altered('foo.css', "$dir/foo.css.php")) { // use the view for BC }

Parameters
string$viewView name. E.g. "elgg/init.js"
string$pathAbsolute file path, or path relative to the viewtype directory. E.g. "elgg/init.js.php"
Returns
bool
Examples:
/root/Elgg/engine/lib/views.php.

Definition at line 1722 of file views.php.

_elgg_view_under_viewtype (   $view,
  $vars,
  $viewtype 
)

Render a view while the global viewtype is temporarily changed.

This makes sure that nested views use the same viewtype.

Parameters
string$viewView name
array$varsView vars
string$viewtypeTemporary viewtype ('' to leave current)
Returns
mixed
Examples:
/root/Elgg/engine/lib/output.php, and /root/Elgg/engine/lib/views.php.

Definition at line 1926 of file views.php.

_elgg_views_amd (   $hook,
  $type,
  $content,
  $params 
)

Inserts module names into anonymous modules by handling the "simplecache:generate" and "cache:generate" hook.

Parameters
string$hookThe name of the hook
string$typeView type (css, js, or unknown)
string$contentContent of the view
array$paramsArray of parameters
Returns
string|null View content minified (if css/js type)
Examples:
/root/Elgg/engine/lib/views.php.

Definition at line 1679 of file views.php.

_elgg_views_file_help_upload_limit ( \Elgg\Hook  $hook)

Add a help text to input/file about upload limit.

In order to not show the help text supply 'show_upload_limit' => false to elgg_view_field()

Parameters
\Elgg\Hook$hook'view_vars' 'elements/forms/help'
Returns
void|array
Examples:
/root/Elgg/engine/lib/views.php.

Definition at line 1979 of file views.php.

_elgg_views_minify (   $hook,
  $type,
  $content,
  $params 
)

Minifies simplecache CSS and JS views by handling the "simplecache:generate" hook.

Parameters
string$hookThe name of the hook
string$typeView type (css, js, or unknown)
string$contentContent of the view
array$paramsArray of parameters
Returns
string|null View content minified (if css/js type)
Examples:
/root/Elgg/engine/lib/views.php.

Definition at line 1634 of file views.php.

_elgg_views_prepare_favicon_links (   $hook,
  $type,
  $head_params,
  $params 
)

Add favicon link tags to HTML head.

Parameters
string$hook"head"
string$type"page"
array$head_paramsHead params [ 'title' => '', 'metas' => [], 'links' => [], ]
array$paramsHook params
Returns
array
Examples:
/root/Elgg/engine/lib/views.php.

Definition at line 519 of file views.php.

_elgg_views_prepare_head (   $title)

Prepare the variables for the html head.

Parameters
string$titlePage title for <head>
Returns
array
Examples:
/root/Elgg/engine/lib/views.php.

Definition at line 447 of file views.php.

_elgg_views_preprocess_css (   $hook,
  $type,
  $content,
  $params 
)

Preprocesses CSS views sent by /cache URLs.

Parameters
string$hookThe name of the hook "simplecache:generate" or "cache:generate"
string$type"css"
string$contentContent of the view
array$paramsArray of parameters
Returns
string|null View content
Examples:
/root/Elgg/engine/lib/views.php.

Definition at line 1663 of file views.php.

_elgg_views_send_header_x_frame_options ( )

Sends X-Frame-Options header on page requests.

Returns
void
Examples:
/root/Elgg/engine/lib/views.php.

Definition at line 1691 of file views.php.

autoregister_views (   $view_base,
  $folder,
  $ignored,
  $viewtype 
)

Auto-registers views from a location.

Note
Views in plugin/views/ are automatically registered for active plugins. Plugin authors would only need to call this if optionally including an entire views structure.
Parameters
string$view_baseOptional The base of the view name without the view type.
string$folderRequired The folder to begin looking in
string$ignoredThis argument is ignored
string$viewtypeThe type of view we're looking at (default, rss, etc)
Returns
bool returns false if folder can't be read
Since
1.7.0
See also
elgg_set_view_location()
Examples:
/root/Elgg/engine/lib/views.php.

Definition at line 1619 of file views.php.

elgg_does_viewtype_fallback (   $viewtype)

Checks if a viewtype falls back to default.

Parameters
string$viewtypeViewtype
Returns
boolean
Since
1.7.2
Examples:
/root/Elgg/engine/lib/views.php.

Definition at line 118 of file views.php.

elgg_extend_view (   $view,
  $view_extension,
  $priority = 501 
)

Extends a view with another view.

The output of any view can be prepended or appended to any other view.

The default action is to append a view. If the priority is less than 500, the output of the extended view will be appended to the original view.

Views can be extended multiple times, and extensions are not checked for uniqueness. Use elgg_unextend_view() to help manage duplicates.

Priority can be specified and affects the order in which extensions are appended or prepended.

See also
elgg_prepend_css_urls() If the extension is CSS, you may need to use this to fix relative URLs.
Parameters
string$viewThe view to extend.
string$view_extensionThis view is added to $view
int$priorityThe priority, from 0 to 1000, to add at (lowest numbers displayed first)
Returns
void
Since
1.7.0
Examples:
/root/Elgg/engine/lib/views.php.

Definition at line 293 of file views.php.

elgg_get_form_footer ( )

Returns currently set footer, or false if not in the form rendering stack.

Returns
string|false
Examples:
/root/Elgg/engine/lib/views.php.

Definition at line 1339 of file views.php.

elgg_get_view_extensions (   $view)

Get the views (and priorities) that extend a view.

Note
extensions may change anytime, especially during the [init, system] event
Parameters
string$viewView name
Returns
string[] Keys returned are view priorities.
Since
2.3
Examples:
/root/Elgg/engine/lib/views.php.

Definition at line 320 of file views.php.

elgg_get_viewtype ( )

Return the current view type.

Viewtypes are automatically detected and can be set with $_REQUEST['view'] or elgg_set_viewtype().

Returns
string The viewtype
See also
elgg_set_viewtype()
Examples:
/root/Elgg/engine/lib/views.php.

Definition at line 78 of file views.php.

elgg_list_views (   $viewtype = 'default')

List all views in a viewtype.

Parameters
string$viewtypeViewtype
Returns
string[]
Since
2.0
Examples:
/root/Elgg/engine/lib/views.php.

Definition at line 218 of file views.php.

elgg_prepend_css_urls (   $css,
  $path 
)

In CSS content, prepend a path to relative URLs.

This is useful to process a CSS view being used as an extension.

Parameters
string$cssCSS
string$pathPath to prepend. E.g. "foo/bar/" or "../"
Returns
string
Since
2.2
Examples:
/root/Elgg/engine/lib/views.php.

Definition at line 337 of file views.php.

elgg_register_ajax_view (   $view)

Register a view to be available for ajax calls.

Warning
Only views that begin with 'js/' and 'css/' have their content type set to 'text/javascript' and 'text/css'. Other views are served as 'text/html'.
Parameters
string$viewThe view name
Returns
void
Since
1.8.3
Examples:
/root/Elgg/engine/lib/views.php.

Definition at line 133 of file views.php.

elgg_register_external_view (   $view,
  $cacheable = false 
)

Registers a view as being available externally (i.e.

via URL).

Parameters
string$viewThe name of the view.
boolean$cacheableWhether this view can be cached.
Returns
void
Since
1.9.0
Examples:
/root/Elgg/engine/lib/views.php.

Definition at line 156 of file views.php.

elgg_register_rss_link ( )

Include the RSS icon link and link element in the head.

Returns
void
Examples:
/root/Elgg/engine/lib/views.php.

Definition at line 1575 of file views.php.

elgg_register_viewtype_fallback (   $viewtype)

Register a viewtype to fall back to a default view if a view isn't found for that viewtype.

This is useful for alternate html viewtypes (such as for mobile devices).

Parameters
string$viewtypeThe viewtype to register
Returns
void
Since
1.7.2
Examples:
/root/Elgg/engine/lib/views.php.

Definition at line 106 of file views.php.

elgg_set_form_footer (   $footer = '')

Sets form footer and defers its rendering until the form view and extensions have been rendered.

Deferring footer rendering allows plugins to extend the form view while maintaining logical DOM structure. Footer will be rendered using 'elements/forms/footer' view after form body has finished rendering

Parameters
string$footerFooter
Returns
bool
Examples:
/root/Elgg/engine/lib/views.php.

Definition at line 1331 of file views.php.

elgg_set_view_location (   $view,
  $location,
  $viewtype = '' 
)

Set an alternative base location for a view.

Views are expected to be in plugin_name/views/. This function can be used to change that location.

This is useful to optionally register views in a plugin.

Parameters
string$viewThe name of the view
string$locationThe full path to the view
string$viewtypeThe view type
Returns
void
Examples:
/root/Elgg/engine/lib/views.php.

Definition at line 190 of file views.php.

elgg_set_viewtype (   $viewtype = '')

Manually set the viewtype.

View types are detected automatically. This function allows you to force subsequent views to use a different viewtype.

Call elgg_set_viewtype() with no parameter to reset.

Parameters
string$viewtypeThe view type, e.g. 'rss', or 'default'.
Returns
bool
Examples:
/root/Elgg/engine/lib/views.php.

Definition at line 65 of file views.php.

elgg_unextend_view (   $view,
  $view_extension 
)

Unextends a view.

Parameters
string$viewThe view that was extended.
string$view_extensionThis view that was added to $view
Returns
bool
Since
1.7.2
Examples:
/root/Elgg/engine/lib/views.php.

Definition at line 306 of file views.php.

elgg_unregister_ajax_view (   $view)

Unregister a view for ajax calls.

Parameters
string$viewThe view name
Returns
void
Since
1.8.3
Examples:
/root/Elgg/engine/lib/views.php.

Definition at line 144 of file views.php.

elgg_unregister_external_view (   $view)

Unregister a view for ajax calls.

Parameters
string$viewThe view name
Returns
void
Since
1.9.0
Examples:
/root/Elgg/engine/lib/views.php.

Definition at line 172 of file views.php.

elgg_unregister_rss_link ( )

Remove the RSS icon link and link element from the head.

Returns
void
Examples:
/root/Elgg/engine/lib/views.php.

Definition at line 1584 of file views.php.

elgg_view (   $view,
  $vars = [],
  $viewtype = '' 
)

Return a parsed view.

Views are rendered by a template handler and returned as strings.

Views are called with a special $vars variable set, which includes any variables passed as the second parameter.

The input of views can be intercepted by registering for the view_vars, $view_name plugin hook.

If the input contains the key "__view_output", the view will output this value as a string. No extensions are used, and the "view" hook is not triggered).

The output of views can be intercepted by registering for the view, $view_name plugin hook.

Parameters
string$viewThe name and location of the view to use
array$varsVariables to pass to the view.
string$viewtypeIf set, forces the viewtype for the elgg_view call to be this value (default: standard detection)
Returns
string The parsed view
Examples:
/root/Elgg/engine/classes/Elgg/FormsService.php, and /root/Elgg/engine/lib/views.php.

Definition at line 246 of file views.php.

elgg_view_annotation ( \ElggAnnotation  $annotation,
array  $vars = [] 
)

Returns a string of a rendered annotation.

Annotation views are expected to be in annotation/$annotation_name. If a view is not found for $annotation_name, the default annotation/default will be used.

Warning
annotation/default is not currently defined in core.

The annotation view is called with the following in $vars:

  • 'annotation' The annotation being viewed.
Parameters
\ElggAnnotation$annotationThe annotation to display
array$varsVariable array for view. 'item_view' Alternative view used to render an annotation
Returns
string|false Rendered annotation
Examples:
/root/Elgg/engine/lib/views.php.

Definition at line 940 of file views.php.

elgg_view_annotation_list (   $annotations,
array  $vars = [] 
)

Returns a rendered list of annotations, plus pagination.

This function should be called by wrapper functions.

Parameters
array$annotationsArray of annotations
array$varsDisplay variables 'count' The total number of annotations across all pages 'offset' The current indexing offset 'limit' The number of annotations to display per page 'full_view' Display the full view of the annotation? 'list_class' CSS Class applied to the list 'item_view' Alternative view to render list items 'offset_key' The url parameter key used for offset 'no_results' Message to display if no results (string|true|Closure)
Returns
string The list of annotations
Examples:
/root/Elgg/engine/lib/views.php.

Definition at line 1046 of file views.php.

elgg_view_comments (   $entity,
  $add_comment = true,
array  $vars = [] 
)

Returns rendered comments and a comment form for an entity.

Plugins can override the output by registering a handler for the comments, $entity_type hook. The handler is responsible for formatting the comments and the add comment form.

Parameters
\ElggEntity$entityThe entity to view comments of
bool$add_commentInclude a form to add comments?
array$varsVariables to pass to comment view
Returns
string|false Rendered comments or false on failure
Examples:
/root/Elgg/engine/lib/views.php.

Definition at line 1141 of file views.php.

elgg_view_deprecated (   $view,
array  $vars,
  $suggestion,
  $version 
)

Display a view with a deprecation notice.

No missing view NOTICE is logged

Parameters
string$viewThe name and location of the view to use
array$varsVariables to pass to the view
string$suggestionSuggestion with the deprecation message
string$versionHuman-readable release version: 1.7, 1.8, ...
Returns
string The parsed view
See also
elgg_view()
Examples:
/root/Elgg/engine/lib/views.php.

Definition at line 266 of file views.php.

elgg_view_entity ( \ElggEntity  $entity,
array  $vars = [] 
)

Returns a string of a rendered entity.

Entity views are either determined by setting the view property on the entity or by having a view named after the entity $type/$subtype. Entities that have neither a view property nor a defined $type/$subtype view will fall back to using the $type/default view.

The entity view is called with the following in $vars:

  • 'entity' The entity being viewed

This function can automatically appends annotations to entities if in full view and a handler is registered for the entity:annotate. See https://github.com/Elgg/Elgg/issues/964 and elgg_view_entity_annotations().

Parameters
\ElggEntity$entityThe entity to display
array$varsArray of variables to pass to the entity view. 'full_view' Whether to show a full or condensed view. (Default: true) 'item_view' Alternative view used to render this entity 'register_rss_link' Register the rss link availability (default: depending on full_view)
Returns
false|string HTML to display or false
Examples:
/root/Elgg/engine/lib/views.php.

Definition at line 842 of file views.php.

elgg_view_entity_annotations ( \ElggEntity  $entity,
  $full_view = true 
)

Display a plugin-specified rendered list of annotations for an entity.

This displays the output of functions registered to the entity:annotation, $entity_type plugin hook.

This is called automatically by the framework from elgg_view_entity()

Parameters
\ElggEntity$entityEntity
bool$full_viewDisplay full view?
Returns
mixed string or false on failure
Examples:
/root/Elgg/engine/lib/views.php.

Definition at line 1080 of file views.php.

elgg_view_entity_icon ( \ElggEntity  $entity,
  $size = 'medium',
  $vars = [] 
)

View the icon of an entity.

Entity views are determined by having a view named after the entity $type/$subtype. Entities that do not have a defined icon/$type/$subtype view will fall back to using the icon/$type/default view.

Parameters
\ElggEntity$entityThe entity to display
string$sizeThe size: tiny, small, medium, large
array$varsAn array of variables to pass to the view. Some possible variables are img_class and link_class. See the specific icon view for more parameters.
Returns
string HTML to display or false
Examples:
/root/Elgg/engine/lib/views.php.

Definition at line 899 of file views.php.

elgg_view_entity_list (   $entities,
array  $vars = [] 
)

Returns a rendered list of entities with pagination.

This function should be called by wrapper functions.

See also
elgg_list_entities()
Parameters
array$entitiesArray of entities
array$varsDisplay variables 'count' The total number of entities across all pages 'offset' The current indexing offset 'limit' The number of entities to display per page (default from settings) 'full_view' Display the full view of the entities? 'list_class' CSS class applied to the list 'item_class' CSS class applied to the list items 'item_view' Alternative view to render list items content 'list_item_view' Alternative view to render list items 'pagination' Display pagination? 'base_url' Base URL of list (optional) 'url_fragment' URL fragment to add to links if not present in base_url (optional) 'position' Position of the pagination: before, after, or both 'list_type' List type: 'list' (default), 'gallery' 'list_type_toggle' Display the list type toggle? 'no_results' Message to display if no results (string|true|Closure)
Returns
string The rendered list of entities
Examples:
/root/Elgg/engine/lib/views.php.

Definition at line 996 of file views.php.

elgg_view_exists (   $view,
  $viewtype = '',
  $recurse = true 
)

Returns whether the specified view exists.

Note
If $recurse is true, also checks if a view exists only as an extension.
Parameters
string$viewThe view name
string$viewtypeIf set, forces the viewtype
bool$recurseIf false, do not check extensions
Returns
bool
Examples:
/root/Elgg/engine/lib/output.php, and /root/Elgg/engine/lib/views.php.

Definition at line 205 of file views.php.

elgg_view_field ( array  $params = [])

Renders a form field, usually with a wrapper element, a label, help text, etc.

Parameters
array$paramsField parameters and variables for the input view. Keys not prefixed with hash (#) are passed to the input view as $vars. Keys prefixed with a hash specify the field wrapper (.elgg-view-field) output.
  • #type: specifies input view. E.g. "text" uses the view "input/text".
  • label: field label HTML
  • #help: field help HTML
  • class: field class name
  • view: custom view to use to render the field
  • #html: can be used to render custom HTML instead of in put field, helpful when you need to add a help paragraph or similar Note: Both label and #help are printed unescaped within their wrapper element. Note: Some fields (like input/checkbox) need special attention because label and label serve different purposes "#label" will be used as a label in the field wrapper but "label" will be used in the input view
Returns
string
Since
2.3
Examples:
/root/Elgg/engine/lib/views.php.

Definition at line 1395 of file views.php.

elgg_view_form (   $action,
  $form_vars = [],
  $body_vars = [] 
)
Examples:
/root/Elgg/engine/lib/views.php.

Definition at line 1318 of file views.php.

elgg_view_friendly_time (   $time)

Displays a UNIX timestamp in a friendly way.

See also
elgg_get_friendly_time()
Parameters
int$timeA UNIX epoch timestamp
Returns
string The friendly time HTML
Since
1.7.2
Examples:
/root/Elgg/engine/lib/views.php.

Definition at line 1120 of file views.php.

elgg_view_icon (   $name,
  $vars = [] 
)

View an icon glyph.

Parameters
string$nameThe specific icon to display
mixed$varsThe additional classname as a string ('float', 'float-alt' or a custom class) or an array of variables (array('class' => 'float')) to pass to the icon view.
Returns
string The html for displaying an icon
Exceptions
InvalidArgumentException
Examples:
/root/Elgg/engine/lib/views.php.

Definition at line 1552 of file views.php.

elgg_view_image_block (   $image,
  $body,
  $vars = [] 
)

Wrapper function for the image block display pattern.

Fixed width media on the side (image, icon, flash, etc.). Descriptive content filling the rest of the column.

Note
Use the $vars "image_alt" key to set an image on the right. If you do, you may pass in an empty string for $image to have only the right image.

This is a shortcut for { page/components/image_block}.

Parameters
string$imageThe icon and other information
string$bodyDescription content
array$varsAdditional parameters for the view
Returns
string
Since
1.8.0
Examples:
/root/Elgg/engine/lib/views.php.

Definition at line 1177 of file views.php.

elgg_view_layout (   $layout_name,
  $vars = [] 
)

Displays a layout with optional parameters.

Layouts are templates provide consistency by organizing blocks of content on the page.

Plugins should use one of the core layouts:

  • default Primary template with one, two or no sidebars
  • admin Admin page template
  • error Error page template
  • widgets Widgets canvas

Plugins can create and use custom layouts by placing a layout view in "page/layouts/<layout_name>" and calling elgg_view_layout(<layout_name>).

For a full list of parameters supported by each of these layouts see corresponding layout views.

Parameters
string$layout_nameLayout name Corresponds to a view in "page/layouts/<layout_name>".
array$varsLayout parameters An associative array of parameters to pass to the layout hooks and views. Route 'identifier' and 'segments' of the page being rendered will be added to this array automatially, allowing plugins to alter layout views and subviews based on the current route.
Returns
string
Examples:
/root/Elgg/engine/lib/views.php.

Definition at line 593 of file views.php.

elgg_view_list_item (   $item,
array  $vars = [] 
)

View an item in a list.

Parameters
mixed$itemEntity, annotation, river item, or other data
array$varsAdditional parameters for the rendering 'item_view' - Alternative view used to render list items This parameter is required if rendering list items that are not entity, annotation or river
Returns
false|string
Since
1.8.0
Examples:
/root/Elgg/engine/lib/views.php.

Definition at line 1523 of file views.php.

elgg_view_menu (   $menu,
array  $vars = [] 
)

Render a menu.

See also
elgg_register_menu_item() for documentation on adding menu items and navigation.php for information on the different menus available.

This function triggers a 'register', 'menu:<menu name>="">' plugin hook that enables plugins to add menu items just before a menu is rendered. This is used by dynamic menus (menus that change based on some input such as the user hover menu). Using elgg_register_menu_item() in response to the hook can cause incorrect links to show up. See the blog plugin's blog_owner_block_menu() for an example of using this plugin hook.

An additional hook is the 'prepare', 'menu:<menu name>="">' which enables plugins to modify the structure of the menu (sort it, remove items, set variables on the menu items).

Preset (unprepared) menu items passed to the this function with the $vars argument, will be merged with the registered items (registered with elgg_register_menu_item()). The combined set of menu items will be passed to 'register', 'menu:<menu_name>' hook.

Plugins that pass preset menu items to this function and do not wish to be affected by plugin hooks (e.g. if you are displaying multiple menus with the same name on the page) should instead choose a unqie menu name and define a menu_view argument to render menus consistently. For example, if you have multiple 'filter' menus on the page: elgg_view_menu("filter:$uid", [ 'items' => $items, 'menu_view' => 'navigation/menu/filter', ]);

elgg_view_menu() uses views in navigation/menu

Parameters
string | Menu | UnpreparedMenu$menuMenu name (or object)
array$varsAn associative array of display options for the menu.
                     Options include:
                         items => an array of unprepared menu items
                                  as ElggMenuItem or menu item factory options
                         sort_by => string or php callback
                             string options: 'name', 'priority' (default), 'text'
                             or a php callback (a compare function for usort)
                         handler: string the page handler to build action URLs
                         entity: \ElggEntity to use to build action URLs
                         class: string the class for the entire menu.
                         menu_view: name of the view to be used to render the menu
                         show_section_headers: bool show headers before menu sections.
Returns
string
Since
1.8.0
Examples:
/root/Elgg/engine/lib/views.php.

Definition at line 755 of file views.php.

elgg_view_menu_item ( \ElggMenuItem  $item,
array  $vars = [] 
)

Render a menu item (usually as a link)

Parameters
\ElggMenuItem$itemThe menu item
array$varsOptions to pass to output/url if a link
Returns
string
Since
1.9.0
Examples:
/root/Elgg/engine/lib/views.php.

Definition at line 794 of file views.php.

elgg_view_message (   $type,
  $body,
array  $vars = [] 
)

Wrapper function for the message display pattern.

Box with header, body

This is a shortcut for { page/components/message}.

Parameters
string$typeThe type of message (error, success, warning, help, notice)
string$bodyContent of the message
array$varsAdditional parameters for the message
Returns
string
Since
3.0.0
Examples:
/root/Elgg/engine/lib/views.php.

Definition at line 1219 of file views.php.

elgg_view_module (   $type,
  $title,
  $body,
array  $vars = [] 
)

Wrapper function for the module display pattern.

Box with header, body, footer

This is a shortcut for { page/components/module}.

Parameters
string$typeThe type of module (main, info, popup, aside, etc.)
string$titleA title to put in the header
string$bodyContent of the module
array$varsAdditional parameters for the module
Returns
string
Since
1.8.0
Examples:
/root/Elgg/engine/lib/views.php.

Definition at line 1198 of file views.php.

elgg_view_page (   $title,
  $body,
  $page_shell = 'default',
  $vars = [] 
)

Assembles and outputs a full page.

A "page" in Elgg is determined by the current view type and can be HTML for a browser, RSS for a feed reader, or Javascript, PHP and a number of other formats.

For HTML pages, use the 'head', 'page' plugin hook for setting meta elements and links.

Parameters
string$titleTitle
string$bodyBody
string$page_shellOptional page shell to use. See page/shells view directory
array$varsOptional vars array to pass to the page shell. Automatically adds title, body, head, and sysmessages
Returns
string The contents of the page
Since
1.8
Examples:
/root/Elgg/engine/lib/views.php.

Definition at line 360 of file views.php.

elgg_view_resource (   $name,
array  $vars = [] 
)

Render a resource view.

Use this in your page handler to hand off page rendering to a view in "resources/". If not found in the current viewtype, we try the "default" viewtype.

Parameters
string$nameThe view name without the leading "resources/"
array$varsArguments passed to the view
Returns
string
Exceptions
Examples:
/root/Elgg/engine/lib/views.php.

Definition at line 423 of file views.php.

elgg_view_river_item (   $item,
array  $vars = [] 
)

Renders a human-readable representation of a river item.

Parameters
\ElggRiverItem$itemA river item object
array$varsAn array of variables for the view 'item_view' Alternative view to render the item 'register_rss_link' Register the rss link availability (default: false)
Returns
string returns empty string if could not be rendered
Examples:
/root/Elgg/engine/lib/views.php.

Definition at line 1234 of file views.php.

elgg_view_tagcloud ( array  $options = [])

Create a tagcloud for viewing.

Parameters
array$optionsAny elgg_get_tags() options except:
type => must be single entity type

subtype => must be single entity subtype
Returns
string
See also
elgg_get_tags()
Since
1.7.1
Examples:
/root/Elgg/engine/lib/views.php.

Definition at line 1493 of file views.php.

elgg_view_title (   $title,
array  $vars = [] 
)

Renders a title.

This is a shortcut for { page/elements/title}.

Parameters
string$titleThe page title
array$varsView variables (was submenu be displayed? (deprecated))
Returns
string The HTML (etc)
Examples:
/root/Elgg/engine/lib/views.php.

Definition at line 1104 of file views.php.

elgg_views_boot ( )

Initialize viewtypes on system boot event This ensures simplecache is cleared during upgrades.

See #2252

Returns
void
Examples:
/root/Elgg/engine/lib/views.php.

Definition at line 1753 of file views.php.