Author Topic: [TUT] How to add a new, custom PHP page  (Read 19715 times)

0 Members and 1 Guest are viewing this topic.

Rembrandt

  • Guest
[TUT] How to add a new, custom PHP page
« on: January 01, 2011, 11:54:53 AM »
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 &nbsp;".$user_info['user_name']."</b><br>";
      
$my_php .= "as such we register the text below in the 'lang/your language/main.php' &nbsp;<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":
Code: [Select]
<a href="{url_top_images}"><b>{lang_top_images}</b></a>&nbsp;
insert above:
Code: [Select]
<a href="custom.php"><b>{custom_name}</b></a>&nbsp;
search:
Code: [Select]
<p>{error_msg}</p>
and replace:
Code: [Select]
{content}
search:
Code: [Select]
{lang_error}
and replace:
Code: [Select]
{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):
Code: [Select]
<a href="custom.php"><b>{custom_name}</b></a>&nbsp;
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

« Last Edit: January 02, 2011, 07:04:35 AM by Rembrandt »

Offline haider512

  • Full Member
  • ***
  • Posts: 153
    • View Profile
Re: [TUT] How to add a new, custom PHP page
« Reply #1 on: January 01, 2011, 02:19:13 PM »
@ Rembrandt

Many Many Many Many Many Many Many Many Many Many Many Many THanks for this Mod..

Superb..Mate..Many thanks for this mod that you made...


im going to apply it now..

i have question..
will this page will b visible for both guests and users or only users..

Actually i want this page to b visible for both users and and guests..that both can see the page..

so it is possible in this to make the availability of page for both users and guests.??

Rembrandt

  • Guest
Re: [TUT] How to add a new, custom PHP page
« Reply #2 on: January 01, 2011, 03:43:49 PM »
.....
so it is possible in this to make the availability of page for both users and guests.??

 8O 8O remove the example code, and put in your php code.
this is only a example code.

Offline haider512

  • Full Member
  • ***
  • Posts: 153
    • View Profile
Re: [TUT] How to add a new, custom PHP page
« Reply #3 on: January 02, 2011, 06:40:46 AM »
Its working awesome..

The page is working..with what ever changes i do in .html


but i dont understand one thing..

i mean when i do change in main language file it dont appear there..


$lang
['legends_name'] = "Legends";
$lang['support_name'] = "Top Supporters";
$lang['legends_page_title'] = "CUSIT Library Legends";


so the above new language i defined in main.php in my english language..

but it is not appearing when i call in the .html file..

here i used when i call the above language.

{support_name}

i also tried {lang_support_name}

but it didnt worked..

i missed some thing.. please tell me what should i do to use my define language.?

here is the link to my custom page..

http://cusitlibrary.com/legends.php
« Last Edit: January 02, 2011, 06:55:25 AM by haider512 »

Rembrandt

  • Guest
Re: [TUT] How to add a new, custom PHP page
« Reply #4 on: January 02, 2011, 06:59:27 AM »
in custom.php:
search:

$site_template
->register_vars(array( 
  
"content" => $my_php,
 
insert below:

"lang_legends_name" => $lang['legends_name'],
"lang_support_name" => $lang['support_name'],
"lang_legends_page_title" =>$lang['legends_page_title'],


in main.php:

$lang
['legends_name'] = "Legends";
$lang['support_name'] = "Top Supporters";
$lang['legends_page_title'] = "CUSIT Library Legends";


in custom.html:
Code: [Select]
{lang_legends_name}
{lang_support_name}
{lang_legends_page_title}



Offline haider512

  • Full Member
  • ***
  • Posts: 153
    • View Profile
Re: [TUT] How to add a new, custom PHP page
« Reply #5 on: January 02, 2011, 07:18:32 AM »
Awesome Mate...its working great..now..

superb...i added those lines in legends.php and it worked...

Super Super THanks..

Keep Rocking mate..

Ty..

Rembrandt

  • Guest
Re: [TUT] How to add a new, custom PHP page
« Reply #6 on: January 02, 2011, 07:23:35 AM »
i am glad....  :mrgreen: