Use a custom page shell in Elgg

Sometimes it's necessary to use an alternate page layout in Elgg. For example it happens if need to display a view on popup or in iframe. In these cases all we have to do is to override the standard page shell.

Let's say that we need to use a different for the site URL The steps for this customization are:

1. Register a hook for filtering the page shell name

elgg_register_plugin_hook_handler('shell', 'page', 'my_plugin_page_shell');


2. Change page shell according the URL above

function my_plugin_page_shell($hook, $entity_type, $return, $params)
    $identifier = $params['identifier'];
    $segment = $params['segments'][0];
    if ($identifier == 'my_plugin' && $segment == 'custompage') {
        $return = 'new_pageshell';
    // we use our own page shell
    return $return;


3. Create a file my_plugin/veiws/default/page/new_pageshell.php. The content of this file could be something like:

$header = elgg_view('page/elements/custom_header', $vars);
$content = elgg_view('page/elements/body', $vars);
$footer = elgg_view('page/elements/custom_footer', $vars);

$body = <<<__BODY
    <div class="elgg-page-body">
        <div class="elgg-inner">

$body .= elgg_view('page/elements/foot');
$head = elgg_view('page/elements/head', $vars['head']);

$params = array(
    'head' => $head,
    'body' => $body,

if (isset($vars['body_attrs'])) {
    $params['body_attrs'] = $vars['body_attrs'];

echo elgg_view("page/elements/html", $params);


4. The file which handles the, should end like this

$title = $my_plugin_entity->title;
$body = elgg_view('my_plugin/simple_entity_view', array('entity' => $my_plugin_entity));
echo elgg_view_page($title, $body);

Shopping Cart

Your cart is empty.