Elgg
Version 6.1
|
Go to the source code of this file.
Functions | |
elgg_set_viewtype (string $viewtype= '') | |
Manually set the viewtype. More... | |
elgg_get_viewtype () | |
Return the current view type. More... | |
elgg_register_viewtype_fallback (string $viewtype) | |
Register a viewtype to fall back to a default view if a view isn't found for that viewtype. More... | |
elgg_register_ajax_view (string $view) | |
Register a view to be available for ajax calls. More... | |
elgg_unregister_ajax_view (string $view) | |
Unregister a view for ajax calls. More... | |
elgg_view_exists (string $view, string $viewtype= '', bool $recurse=true) | |
Returns whether the specified view exists. More... | |
elgg_view (string $view, array $vars=[], string $viewtype= '') | |
Return a parsed view. More... | |
elgg_extend_view (string $view, string $view_extension, int $priority=501) | |
Extends a view with another view. More... | |
elgg_unextend_view (string $view, string $view_extension) | |
Unextends a view. More... | |
elgg_get_view_extensions (string $view) | |
Get the views (and priorities) that extend a view. More... | |
elgg_view_page (string $title, string|array $body, string $page_shell= 'default', array $vars=[]) | |
Assembles and outputs a full page. More... | |
elgg_view_resource (string $name, array $vars=[]) | |
Render a resource view. More... | |
elgg_view_layout (string $layout_name, array $vars=[]) | |
Displays a layout with optional parameters. More... | |
elgg_view_menu ($menu, array $vars=[]) | |
Render a menu. More... | |
elgg_view_entity (\ElggEntity $entity, array $vars=[]) | |
Returns a string of a rendered entity. More... | |
elgg_view_entity_icon (\ElggEntity $entity, string $size= 'medium', array $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 (array $entities, array $vars=[]) | |
Returns a rendered list of entities with pagination. More... | |
elgg_view_annotation_list (array $annotations, array $vars=[]) | |
Returns a rendered list of annotations, plus pagination. More... | |
elgg_view_relationship_list (array $relationships, array $vars=[]) | |
Returns a rendered list of relationships, plus pagination. More... | |
elgg_view_relationship (\ElggRelationship $relationship, array $vars=[]) | |
Returns a string of a rendered relationship. More... | |
elgg_view_title (string $title, array $vars=[]) | |
Renders a title. More... | |
elgg_view_friendly_time ($time, $time_updated=null) | |
Displays a UNIX timestamp in a friendly way. More... | |
elgg_view_comments (\ElggEntity $entity, bool $add_comment=true, array $vars=[]) | |
Returns rendered comments and a comment form for an entity. More... | |
elgg_view_image_block (string $image, string $body, array $vars=[]) | |
Wrapper function for the image block display pattern. More... | |
elgg_view_module (string $type, string $title, string $body, array $vars=[]) | |
Wrapper function for the module display pattern. More... | |
elgg_view_message (string $type, string $body, array $vars=[]) | |
Wrapper function for the message display pattern. More... | |
elgg_view_river_item (\ElggRiverItem $item, array $vars=[]) | |
Renders a human-readable representation of a river item. More... | |
elgg_view_form (string $action, array $form_vars=[], array $body_vars=[]) | |
elgg_set_form_footer (string $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 (string $name, array $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... | |
elgg_views_boot () | |
Initialize viewtypes on system boot event This ensures simplecache is cleared during upgrades. More... | |
_elgg_get_js_page_data (array $params=[]) | |
Get the initial contents of "elgg" client side. More... | |
_elgg_view_under_viewtype (string $view, array $vars, string $viewtype) | |
Render a view while the global viewtype is temporarily changed. More... | |
elgg_view_url (string $href, string $text=null, array $options=[]) | |
Helper function for outputting urls. More... | |
elgg_view_entity_url (\ElggEntity $entity, array $options=[]) | |
Helper function for outputting a link to an entity. More... | |
elgg_view_deprecated (string $view, array $vars, string $suggestion, string $version) | |
Display a view with a deprecation notice. More... | |
_elgg_get_js_page_data | ( | array | $params = [] | ) |
Get the initial contents of "elgg" client side.
Will be extended by elgg.js.
array | $params | page related parameters |
_elgg_has_rss_link | ( | ) |
Should the RSS view of this URL be linked to?
_elgg_split_vars | ( | array | $vars = [] , |
array | $prefixes = null |
||
) |
Split array of vars into subarrays based on property prefixes.
array | $vars | Vars to split |
array | $prefixes | Prefixes to split |
_elgg_view_under_viewtype | ( | string | $view, |
array | $vars, | ||
string | $viewtype | ||
) |
Render a view while the global viewtype is temporarily changed.
This makes sure that nested views use the same viewtype.
string | $view | View name |
array | $vars | View vars |
string | $viewtype | Temporary viewtype ('' to leave current) |
elgg_extend_view | ( | string | $view, |
string | $view_extension, | ||
int | $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.
string | $view | The view to extend. |
string | $view_extension | This view is added to $view |
int | $priority | The priority, from 0 to 1000, to add at (lowest numbers displayed first) |
elgg_get_form_footer | ( | ) |
Returns currently set footer, or false if not in the form rendering stack.
elgg_get_view_extensions | ( | string | $view | ) |
Get the views (and priorities) that extend a view.
string | $view | View name |
elgg_get_viewtype | ( | ) |
Return the current view type.
Viewtypes are automatically detected and can be set with $_REQUEST['view'] or elgg_set_viewtype().
elgg_register_ajax_view | ( | string | $view | ) |
Register a view to be available for ajax calls.
string | $view | The view name |
elgg_register_rss_link | ( | ) |
Include the RSS icon link and link element in the head.
elgg_register_viewtype_fallback | ( | string | $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).
string | $viewtype | The viewtype to register |
elgg_set_form_footer | ( | string | $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
string | $footer | Footer |
elgg_set_viewtype | ( | string | $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.
string | $viewtype | The view type, e.g. 'rss', or 'default'. |
elgg_unextend_view | ( | string | $view, |
string | $view_extension | ||
) |
Unextends a view.
string | $view | The view that was extended. |
string | $view_extension | This view that was added to $view |
elgg_unregister_ajax_view | ( | string | $view | ) |
Unregister a view for ajax calls.
string | $view | The view name |
elgg_unregister_rss_link | ( | ) |
Remove the RSS icon link and link element from the head.
elgg_view | ( | string | $view, |
array | $vars = [] , |
||
string | $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>="">' event.
If the input contains the key "__view_output", the view will output this value as a string. No extensions are used, and the "view" event is not triggered).
The output of views can be intercepted by registering for the 'view', '< $view_name>="">' event.
string | $view | The name and location of the view to use |
array | $vars | Variables to pass to the view. |
string | $viewtype | If set, forces the viewtype for the elgg_view call to be this value (default: standard detection) |
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.
The annotation view is called with the following in $vars:
\ElggAnnotation | $annotation | The annotation to display |
array | $vars | Variable array for view. 'item_view' Alternative view used to render an annotation |
elgg_view_annotation_list | ( | array | $annotations, |
array | $vars = [] |
||
) |
Returns a rendered list of annotations, plus pagination.
This function should be called by wrapper functions.
array | $annotations | Array of annotations |
array | $vars | Display 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 'list_type' List type: 'list' (default), 'gallery' '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) |
elgg_view_comments | ( | \ElggEntity | $entity, |
bool | $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>="">' event. The handler is responsible for formatting the comments and the add comment form.
\ElggEntity | $entity | The entity to view comments of |
bool | $add_comment | Include a form to add comments? |
array | $vars | Variables to pass to comment view |
elgg_view_deprecated | ( | string | $view, |
array | $vars, | ||
string | $suggestion, | ||
string | $version | ||
) |
Display a view with a deprecation notice.
No missing view NOTICE is logged
string | $view | The name and location of the view to use |
array | $vars | Variables to pass to the view |
string | $suggestion | Suggestion with the deprecation message |
string | $version | Human-readable release version: 1.7, 1.8, ... |
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:
\ElggEntity | $entity | The entity to display |
array | $vars | Array 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) |
elgg_view_entity_icon | ( | \ElggEntity | $entity, |
string | $size = 'medium' , |
||
array | $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.
\ElggEntity | $entity | The entity to display |
string | $size | The size: tiny, small, medium, large |
array | $vars | An 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. |
elgg_view_entity_list | ( | array | $entities, |
array | $vars = [] |
||
) |
Returns a rendered list of entities with pagination.
This function should be called by wrapper functions.
array | $entities | Array of entities |
array | $vars | Display 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' 'no_results' Message to display if no results (string|true|Closure) |
elgg_view_entity_url | ( | \ElggEntity | $entity, |
array | $options = [] |
||
) |
Helper function for outputting a link to an entity.
\ElggEntity | $entity | The entity to draw the link for |
array | $options | Additional options to pass to the output view |
elgg_view_exists | ( | string | $view, |
string | $viewtype = '' , |
||
bool | $recurse = true |
||
) |
Returns whether the specified view exists.
string | $view | The view name |
string | $viewtype | If set, forces the viewtype |
bool | $recurse | If false, do not check extensions |
elgg_view_field | ( | array | $params = [] | ) |
Renders a form field, usually with a wrapper element, a label, help text, etc.
array | $params | Field 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.
|
elgg_view_form | ( | string | $action, |
array | $form_vars = [] , |
||
array | $body_vars = [] |
||
) |
elgg_view_friendly_time | ( | $time, | |
$time_updated = null |
|||
) |
Displays a UNIX timestamp in a friendly way.
int | string | \DateTime | \Elgg\I18n\DateTime | $time | A UNIX epoch timestamp, a date string or a DateTime object |
int | string | \DateTime | \Elgg\I18n\DateTime | $time_updated | A UNIX epoch timestamp, a date string or a DateTime object |
elgg_view_icon | ( | string | $name, |
array | $vars = [] |
||
) |
View an icon glyph.
string | $name | The specific icon to display |
array | $vars | An array of variables (['class' => 'float']) to pass to the icon view. |
elgg_view_image_block | ( | string | $image, |
string | $body, | ||
array | $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.
This is a shortcut for { page/components/image_block}.
string | $image | The icon and other information |
string | $body | Description content |
array | $vars | Additional parameters for the view |
elgg_view_layout | ( | string | $layout_name, |
array | $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:
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.
string | $layout_name | Layout name Corresponds to a view in "page/layouts/<layout_name>". |
array | $vars | Layout parameters An associative array of parameters to pass to the layout events 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. |
elgg_view_list_item | ( | $item, | |
array | $vars = [] |
||
) |
View an item in a list.
mixed | $item | Entity, annotation, river item, or other data |
array | $vars | Additional parameters for the rendering 'item_view' - Alternative view used to render list items (required if rendering list items that are not entity, annotation, relationship or river) |
elgg_view_menu | ( | $menu, | |
array | $vars = [] |
||
) |
Render a menu.
This function triggers a 'register', 'menu:<menu name>="">' event 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 event can cause incorrect links to show up. See the blog plugin's blog_owner_block_menu() for an example of using this event.
An additional event 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>' event.
Plugins that pass preset menu items to this function and do not wish to be affected by events (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
Commonly used menu vars: items => (array) 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 => () entity to use to build action URLs class => (string) the class for the entire menu menu_view => (string) name of the view to be used to render the menu show_section_headers => (bool) show headers before menu sections selected_item_name => (string) the menu item name to be selected prepare_vertical => (bool) prepares the menu items for vertical display (default false) prepare_dropdown => (bool) will put all menu items (section=default) behind a dropdown (default false) item_contents_view => (string) the view to use for the output of the menu item contents (default: 'navigation/menu/elements/item/url')
string | Menu | UnpreparedMenu | $menu | Menu name (or object) |
array | $vars | An associative array of display options for the menu. |
elgg_view_message | ( | string | $type, |
string | $body, | ||
array | $vars = [] |
||
) |
Wrapper function for the message display pattern.
Box with header, body
This is a shortcut for { page/components/message}.
string | $type | The type of message (error, success, warning, help, notice) |
string | $body | Content of the message |
array | $vars | Additional parameters for the message |
elgg_view_module | ( | string | $type, |
string | $title, | ||
string | $body, | ||
array | $vars = [] |
||
) |
Wrapper function for the module display pattern.
Box with header, body, footer
This is a shortcut for { page/components/module}.
string | $type | The type of module (main, info, popup, aside, etc.) |
string | $title | A title to put in the header |
string | $body | Content of the module |
array | $vars | Additional parameters for the module |
elgg_view_page | ( | string | $title, |
string|array | $body, | ||
string | $page_shell = 'default' , |
||
array | $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' event for setting meta elements and links.
string | $title | Title |
string | array | $body | Body as a string or as an array (which will be passed to elgg_view_layout('default', $body) |
string | $page_shell | Optional page shell to use. See page/shells view directory |
array | $vars | Optional vars array to pass to the page shell. Automatically adds title, body, head, and sysmessages |
elgg_view_relationship | ( | \ElggRelationship | $relationship, |
array | $vars = [] |
||
) |
Returns a string of a rendered relationship.
Relationship views are expected to be in relationship/$relationship_name. If a view is not found for $relationship_name, the default relationship/default will be used.
The relationship view is called with the following in $vars:
\ElggRelationship | $relationship | The relationship to display |
array | $vars | Variable array for view. 'item_view' Alternative view used to render a relationship |
elgg_view_relationship_list | ( | array | $relationships, |
array | $vars = [] |
||
) |
Returns a rendered list of relationships, plus pagination.
This function should be called by wrapper functions.
array | $relationships | Array of relationships |
array | $vars | Display variables 'count' The total number of relationships across all pages 'offset' The current indexing offset 'limit' The number of relationships to display per page 'full_view' Display the full view of the relationships? 'list_class' CSS Class applied to the list 'list_type' List type: 'list' (default), 'gallery' '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) |
elgg_view_resource | ( | string | $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.
string | $name | The view name without the leading "resources/" |
array | $vars | Arguments passed to the view |
PageNotFoundException |
elgg_view_river_item | ( | \ElggRiverItem | $item, |
array | $vars = [] |
||
) |
Renders a human-readable representation of a river item.
\ElggRiverItem | $item | A river item object |
array | $vars | An array of variables for the view 'item_view' Alternative view to render the item 'register_rss_link' Register the rss link availability (default: false) |
elgg_view_tagcloud | ( | array | $options = [] | ) |
Create a tagcloud for viewing.
array | $options | Any elgg_get_tags() options except:
|
elgg_view_title | ( | string | $title, |
array | $vars = [] |
||
) |
Renders a title.
This is a shortcut for { page/elements/title}.
string | $title | The page title |
array | $vars | View variables |
elgg_view_url | ( | string | $href, |
string | $text = null , |
||
array | $options = [] |
||
) |
Helper function for outputting urls.
Using this helper function defaults to trusted urls
string | $href | The URL |
string | $text | The visible text |
array | $options | Additional options to pass to the output/url View |
elgg_views_boot | ( | ) |
Initialize viewtypes on system boot event This ensures simplecache is cleared during upgrades.
See #2252