Elgg  Version master
Functions
context.php File Reference

Go to the source code of this file.

Functions

 elgg_set_context (string $context)
 Elgg context library. More...
 
 elgg_get_context ()
 Get the current context. More...
 
 elgg_push_context (string $context)
 Push a context onto the top of the stack. More...
 
 elgg_pop_context ()
 Removes and returns the top context string from the stack. More...
 
 elgg_in_context (string $context)
 Check if this context exists anywhere in the stack. More...
 
 elgg_get_context_stack ()
 Get the entire context stack (e.g. More...
 
 elgg_set_context_stack (array $stack)
 Set the entire context stack. More...
 

Function Documentation

elgg_get_context ( )

Get the current context.

Since context is a stack, this is equivalent to a peek.

Returns
string|null
Since
1.8.0

Definition at line 41 of file context.php.

elgg_get_context_stack ( )

Get the entire context stack (e.g.

for backing it up)

Returns
string[]
Since
1.11

Definition at line 88 of file context.php.

elgg_in_context ( string  $context)

Check if this context exists anywhere in the stack.

This is useful for situations with more than one element in the stack. For example, a widget has a context of 'widget'. If a widget view needs to render itself differently based on being on the dashboard or profile pages, it can check the stack.

Parameters
string$contextThe context string to check for
Returns
bool
Since
1.8.0

Definition at line 78 of file context.php.

elgg_pop_context ( )

Removes and returns the top context string from the stack.

Returns
string|null
Since
1.8.0

Definition at line 62 of file context.php.

elgg_push_context ( string  $context)

Push a context onto the top of the stack.

Parameters
string$contextThe context string to add to the context stack
Returns
void
Since
1.8.0

Definition at line 52 of file context.php.

elgg_set_context ( string  $context)

Elgg context library.

Sets the page context

Views can modify their output based on the local context. You may want to display a list of blogs on a blog page or in a small widget. The rendered output could be different for those two contexts ('blog' vs 'widget').

Pages that pass through the page handling system set the context to the first string after the root url. Example: http://example.org/elgg/bookmarks/ results in the initial context being set to 'bookmarks'.

The context is a stack so that for a widget on a profile, the context stack may contain first 'profile' and then 'widget'.

If no context was been set, the default context returned is 'main'.

Warning
The context is not available until the page_handler runs (after the 'init, system' event processing has completed).
Parameters
string$contextThe context of the page
Returns
bool
Since
1.8.0

Definition at line 29 of file context.php.

elgg_set_context_stack ( array  $stack)

Set the entire context stack.

Parameters
string[]$stack All contexts to be placed on the stack
Returns
void
Since
1.11

Definition at line 99 of file context.php.