How to add a new, custom PHP page
I've put in all the files important comment texts written.
I think, then everyone knows.
Example:
1.) copy the text below, call it "custom.php" and store it in your galerie root:
<?php
/**************************************************************************
* *
* 4images - A Web Based Image Gallery Management System *
* ---------------------------------------------------------------- *
* *
* File: custom.php *
* Copyright: (C) 2002-2009 Jan Sorgalla *
* Email: jan@4homepages.de *
* Web: http://www.4homepages.de *
* Scriptversion: 1.7.9 *
* File Version: 1.0.0 (by Rembrandt www.vienna-pictures.com) *
* Never released without support from: Nicky (http://www.nicky.net) *
* *
**************************************************************************
* *
* Dieses Script ist KEINE Freeware. Bitte lesen Sie die Lizenz- *
* bedingungen (Lizenz.txt) für weitere Informationen. *
* --------------------------------------------------------------- *
* This script is NOT freeware! Please read the Copyright Notice *
* (Licence.txt) for further information. *
* *
*************************************************************************/
$main_template = 'custom'; // <-- Your Template Title
define('GET_CACHES', 1);
define('ROOT_PATH', './');
define('MAIN_SCRIPT', __FILE__);
include(ROOT_PATH.'global.php');
require(ROOT_PATH.'includes/sessions.php');
include(ROOT_PATH.'includes/page_header.php');
$txt_clickstream = $lang['custom_name']; // <-- Clickstream Name
//################## EXAMPLE CUSTOM PHP CODE STARTS HERE ############################
if ($user_info['user_level'] == GUEST){
$my_php = "You have no Access !<br>";
$my_php .= "Please Login:<br>";
$my_php .= "<a href=\"".$site_sess->url(ROOT_PATH."index.php")."\">Login</a>";
}
else {
$my_php = "<b> Hello ".$user_info['user_name']."</b><br>";
$my_php .= "as such we register the text below in the 'lang/your language/main.php' <br>".$lang['example_text'];
}
//Here starts the lang register
$site_template->register_vars(array(
"content" => $my_php, // <-- It is important that the same name used as in PHP Code above (in this example "my_php")
"lang_custom_page_title" => $lang['custom_page_title'], // <-- Page Title
"lang_example_text" => $lang['example_text'] // <-- the "example_text" must still be registered in the "lang/your language/main.php"
));
//################## EXAMPLE CUSTOM PHP CODE END HERE ################################
//-----------------------------------------------------
//--- Clickstream -------------------------------------
//-----------------------------------------------------
$clickstream = "<span class=\"clickstream\"><a href=\"".$site_sess->url(ROOT_PATH."index.php")."\" class=\"clickstream\">".$lang['home']."</a>".$config['category_separator'].$txt_clickstream."</span>";
//-----------------------------------------------------
//--- Print Out ---------------------------------------
//-----------------------------------------------------
$site_template->register_vars(array(
//"content" => $content,
"msg" => $msg,
"clickstream" => $clickstream
));
$site_template->print_template($site_template->parse_template($main_template));
include(ROOT_PATH.'includes/page_footer.php');
?>
2.) copy the error.html from your template, and rename it to "custom.html" and store it in your Template folder.
the code "{content}" here shall displayed your php code from the "custom.php".
the code "{lang_custom_page_title}" here shall displayed your page title.
search in the new "custom.html":
<a href="{url_top_images}"><b>{lang_top_images}</b></a>
insert above:
<a href="custom.php"><b>{custom_name}</b></a>
search:
<p>{error_msg}</p>
and replace:
{content}
search:
{lang_error}
and replace:
{lang_custom_page_title}
3.) put the code below where you ever you want in lang/yourlang/main.php (between <?php...?>):
//-----------------------------------------------------
//------------------ Custom ---------------------------
//-----------------------------------------------------
$lang['custom_name'] = "My first PHP Template"; // Clickstream Name
$lang['custom_page_title'] = "This is your first custom site"; // Page Title
$lang['example_text'] = "<br><b>This is a Example Text, registered in the \"lang/your language/main.php\"</b>"; // Example Text
4.) so you can access your page, add the following link into all other html pages (where ever you want):
<a href="custom.php"><b>{custom_name}</b></a>
and the link so you can see, he must be registered in the includes/page.header.php:
search in includes/page.header.php:
$site_template->register_vars(array(
"lang_site_stats" => $lang['site_stats'],
insert below:
"custom_name" => $lang['custom_name'],
login as user and as guest, you can see the difference in the "custom.html ".
run your custom page, you can all the comment lines remove from the code.
mfg Andi