Permalink
Browse files

docs(routing): Update custom_index to demonstrate latest best practices

  • Loading branch information...
ewinslow committed Dec 5, 2014
1 parent f1b75bb commit 0142a5f05da1ed596cd9c5a0ef4776d5837056aa
@@ -6,7 +6,7 @@
<version>1.9</version>
<category>bundled</category>
<category>enhancement</category>
<description>A demonstration of how to create a front page plugin.</description>
<description>A demonstration of how to customize your site's homepage.</description>
<website>http://www.elgg.org/</website>
<copyright>See COPYRIGHT.txt</copyright>
<license>GNU General Public License version 2</license>
View
@@ -1,29 +1,16 @@
<?php
/**
* Elgg demo custom index page plugin
*
*/
elgg_register_event_handler('init', 'system', 'custom_index_init');
function custom_index_init() {
// Extend system CSS with our own styles
elgg_extend_view('css/elgg', 'custom_index/css');
// Replace the default index page
elgg_register_page_handler('', 'custom_index');
}
/**
* Serve the front page
*
* @return bool Whether the page was sent.
*/
function custom_index() {
if (!include_once(dirname(__FILE__) . "/index.php")) {
return false;
}
return true;
}
// TODO(ewinslow): Want to just call elgg_load_css('./index.css') in
// the index.php view, but can't because:
// 1. Elgg can only load CSS from views in the css/* folder.
// 2. Elgg can't do relative css inclusion.
// Fix this.
elgg_extend_view('css/elgg', 'resources/index.css');
}
@@ -2,9 +2,8 @@
/**
* Elgg custom index layout
*
* You can edit the layout of this page with your own layout and style.
* Whatever you put in this view will appear on the front page of your site.
*
* This is just a helper view to make it easier to use Elgg's
* page-rendering helper functions like elgg_view_page.
*/
$mod_params = array('class' => 'elgg-module-highlight');
@@ -1,10 +1,3 @@
<?php
/**
* Custom Index CSS
*
*/
?>
/*******************************
Custom Index
********************************/
@@ -2,6 +2,9 @@
/**
* Elgg custom index page
*
* You can edit the content of this page with your own layout and style.
* Whatever you put in this view will appear on the front page of your site.
*
*/
elgg_push_context('front');
@@ -59,7 +62,8 @@
'login' => $login,
'members' => $newest_members,
);
$body = elgg_view_layout('custom_index', $params);
$body = elgg_view('resources/index-content', $params);
// no RSS feed with a "widget" front page
global $autofeed;

0 comments on commit 0142a5f

Please sign in to comment.