Author |
Message |
hanscom
Hangin' Around

Joined: Oct 16, 2003
Posts: 36
|
Posted:
Wed Apr 08, 2009 3:24 am |
|
Hi,
I have several html files in modules/html/.
How can I modify index.php or an other file to use home.html in modules/html/
to become my home page (start page)?
Thanks in advance, Regards.
Hans |
|
|
|
 |
Raven
Site Admin/Owner

Joined: Aug 27, 2002
Posts: 17088
|
Posted:
Wed Apr 08, 2009 10:02 am |
|
The easiest way is to create a new module (folder) and call it whatever you want, like My_Home_Page. Place the My_Home_Page folder in the modules directory/folder.
Now there are several ways to complete this.
Method 1
Copy home.html to your new My_Home_Folder and rename home.html to index.php. Edit index.php and add these 2 lines of code to the top of index.php
Method 2
Don't copy home.html. Instead, create a new file in My_Home_Page and name it index.php. Add the following code to index.phpCode:<?php
if ( !defined('MODULE_FILE') )
{
die('You can\'t access this file directly...');
}
require_once 'mainfile.php';
$module_name = basename(dirname(__FILE__));
/* Only uncomment the next line if you use a language folder */
// get_lang($module_name);
$pagetitle = '- '.$module_name;
include_once 'header.php';
OpenTable();
?>
include_once 'home.html'; // You might have to use '../html/home.html'
<?php
CloseTable();
include 'footer.php';
?>
|
Method 3
Don't copy home.html. Instead, create a new file in My_Home_Page and name it index.php. Add the following code to index.phpCode:<?php
if ( !defined('MODULE_FILE') )
{
die('You can\'t access this file directly...');
}
require_once 'mainfile.php';
$module_name = basename(dirname(__FILE__));
/* Only uncomment the next line if you use a language folder */
// get_lang($module_name);
$pagetitle = '- '.$module_name;
include_once 'header.php';
OpenTable();
/* Insert the [u][[b]contents[/b][/u] of home.html after the NEXT line; inbetween the NEXT 2 lines */
echo <<<_MYHOME_
_MYHOME_;
CloseTable();
include 'footer.php';
?>
|
Then as the last step, regardless of which method you use, using the ACP, activate the new module and click the Put In Home link to make it the Home module.
As I said there are several ways to do the same thing  |
|
|
|
 |
hanscom

|
Posted:
Wed Apr 08, 2009 2:47 pm |
|
I tested all 3 methods and the 2nd one is my favorite.
Thanks for the tips and clear explanation.
Regards, Hans |
|
|
|
 |
Raven

|
Posted:
Wed Apr 08, 2009 10:36 pm |
|
Great! I have modified the subject a little to make it clearer and also made it a sticky  |
|
|
|
 |
hanscom

|
Posted:
Thu Apr 09, 2009 5:12 am |
|
One more question.
I received a tip to place:
header("Location: modules.php?name=html&page=home.html");
exit;
after:
require_once("mainfile.php");
in index.php of php-nuke.
I tested it and it works, but is this a proper method in your opinion? |
|
|
|
 |
Raven

|
Posted:
Thu Apr 09, 2009 12:36 pm |
|
As I said there are several ways to accomplish the end result. I would not prefer that method mainly because it involves an added redirect that isn't needed and it makes the module a non standard way of coding a module. But that's just my opinion/preference. |
|
|
|
 |
hanscom

|
Posted:
Fri Apr 10, 2009 3:53 am |
|
I have decided to stick to method 2.
However, while my 'Home' module has been put in Home, the News message was
also displayed. To avoid this, I had to deactivate News and the message(s) in 'Messages'. I use the Sunset theme. |
|
|
|
 |
Raven

|
Posted:
Fri Apr 10, 2009 6:34 am |
|
hanscom,
If you don't mind, would you please zip up your Home module and a copy of home.html and email the zip file to raven@ravenphpscripts.com ? I'm not understanding why both would display in home. Also, try switching themes to fisbice or RavenIce to see if they behave correctly. Thanks! |
|
|
|
 |
|