Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Ravens PHP Scripts And Web Hosting Forum Index -> phpnuke 7.6
Author Message
hanscom
Hangin' Around



Joined: Oct 16, 2003
Posts: 36

PostPosted: Wed Apr 08, 2009 3:24 am Reply with quote

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
 
View user's profile Send private message
Raven
Site Admin/Owner



Joined: Aug 27, 2002
Posts: 17088

PostPosted: Wed Apr 08, 2009 10:02 am Reply with quote

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
Code:
<?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.php
Code:
<?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.php
Code:
<?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 Smile
 
View user's profile Send private message
hanscom







PostPosted: Wed Apr 08, 2009 2:47 pm Reply with quote

I tested all 3 methods and the 2nd one is my favorite.
Thanks for the tips and clear explanation.
Regards, Hans
 
Raven







PostPosted: Wed Apr 08, 2009 10:36 pm Reply with quote

Great! I have modified the subject a little to make it clearer and also made it a sticky RavensScripts
 
hanscom







PostPosted: Thu Apr 09, 2009 5:12 am Reply with quote

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







PostPosted: Thu Apr 09, 2009 12:36 pm Reply with quote

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







PostPosted: Fri Apr 10, 2009 3:53 am Reply with quote

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







PostPosted: Fri Apr 10, 2009 6:34 am Reply with quote

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 [ Only registered users can see links on this board! Get registered or login! ] ? 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!
 
Display posts from previous:       
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Ravens PHP Scripts And Web Hosting Forum Index -> phpnuke 7.6

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©