How to Add additional php pages, that can call modules(keywords) ELGG 8RC2
From what I have gathered, you need to make two edits in two different files. The first is here at :
\units\templates\default_template.php
lines 32 – 36
Here is what it will look like.
$template['pageshell'] = file_get_contents($CFG->templatesroot . "Default_Template/pageshell");
$template['frontpage_loggedout'] = file_get_contents($CFG->templatesroot . "Default_Template/frontpage_loggedout");
$template['frontpage_loggedin'] = file_get_contents($CFG->templatesroot . "Default_Template/frontpage_loggedin");
$template['test'] = file_get_contents($CFG->templatesroot . "Default_Template/test");
The italic line, is the line i added myself.
The second file you must edit, is here :
/lib/templates.php
lines 68 – 71
Here is what it will look like
$template['pageshell'] = file_get_contents($CFG->templatesroot . "Default_Template/pageshell");
$template['frontpage_loggedout'] = file_get_contents($CFG->templatesroot . "Default_Template/frontpage_loggedout");
$template['frontpage_loggedin'] = file_get_contents($CFG->templatesroot . "Default_Template/frontpage_loggedin");
$template['test'] = file_get_contents($CFG->templatesroot . "Default_Template/test");
The italic line, is the line i added myself.
Finally, you must make a php file that will call it. For this example, i added a file called test.php and uploaded it to the root directory of the installed elgg. So in my case it was www.mydomain.com/elgg/test.php. Here is the content of that file, its the same as your index.php
<?php
global $CFG;
require_once(dirname(__FILE__)."/includes.php");
templates_page_setup();
if (logged_on) {
$body = templates_draw(array(
'context' => 'test'
)
);
} else {
$body = templates_draw(array(
'context' => 'test'
)
);
}
echo templates_page_draw( array(
$CFG->sitename,
$body
)
);
?>
The bold line, is the edited area.
Now, the last thing you need to do, is add a file called “test” to your default template directory.
\mod\template\templates\Default_Template\test
Make sure there is no file extension on the test file. This page will work the same as frontpage_loggedin and frontpage_loggedout.
When you set your browser to elgg\test.php, your content should be displayed.
I dont know if this is perfect and ive yet to test it with multiple themes...
Keywords: additional php pages, elgg 8rc2, elgg keywords, extra content pages, keywords, keywords on pages, modules, pages that can use keywords, php pages