Hi all,
I am currently reading the Elgg1.8 textbook and I have an elgg1.8.1 distribution running locally via xampp on windows 7. When I follow the page handler tutorial and add the page to the site menu, it doesn't load my page. Instead it prints out the default message out of my switch statement. I can't seem to find the error, since my paths are correct. Here is the code:
function au_page_handler($page, $identifier) {
// Path to plugin folder
$plugin_path = elgg_get_plugins_path();
// Pages folder
$base_path = $plugin_path . '<plugin_name>/pages/<plugin_name>';
// Page is selected upon first url segment after /<plugin_name>/
switch($page) {
case '<page_name>':
require "$base_path/<page_name>";
break;
default:
echo "Not Found! $identifier $page[0]";
break;
}
// Confirm to Elgg that page has been sent to browser
return true;
}MY PAGE CODE:
// Title varaible
$title = "Title of page";
// Content varaible
$content = "Content here";
// Set metadata for the page
$vars = array(
'content' => $content,
);
// Creates body of the page.
$body = elgg_view_layout('one_sidebar', $vars);
// Next line passes the title and the body to the elgg function.
echo elgg_view_page($title, $body);
Any advice is greatly appreciated.
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by RaĆ¼l Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.
- Mark@Zander1983
Mark - 0 likes
- Southpaw Development@DanielHamacher
Southpaw Development - 0 likes
You must log in to post replies.$page is an array, so try $page[0], as in switch($page[0])
Works. Thank you very much.