Dynamic Multiple Pages
From Hack Wars Wiki
Contents |
HTTP
This approach is similar to Multiple Pages script except that this version does not require a recompile to add more pages.
HTTP: ENTER
Add this code to the ENTER section of a new HTTP Script (Applications > Script Editor > File > New > HTTP Script)
// Apache v1 by Dllfile int main() { // Gets the value of p to determine // which file to look for. string p = fetchGetVariable("p"); // Takes care of first page load // Defaults the page to index // if page is not defined. if (p == "") { p = "index"; } // Can replace if you like or keep // the naming convention. file.html p = "web/" + p + ".html"; // Replaces <?content?> in your site // template with the contents of the // file being loaded. replaceContent("content", readFile(p)); } |
Like Multiple Pages script, you can leave Submit and Leave sections empty or use your own code.
Compile and Install the script, then proceed to Template below.
Template
Go into Applications > Internet > Site Editor and paste in the template below as a base to start with. Be sure to replace YOURIP with your actual ingame IP Address.
<html> <head> <title></title> </head> <body> <!-- Begin Menu --> <div align="center"> <a href="YOURIP">Home</a> </div> <br /><br /> <!-- End Menu --> <?content?> </body> </html> |
Files
In your Home directory (Places > Home), click the folder icon to create a new folder and name it web
Next open Script Editor (Applications > Script Editor) then create a new Text File (File > New > Text Document)
Copy/Paste in the below code and then save the new file into the folder named web, be sure to name it index.html
<div align="center"> <strong>My first dynamic page!</strong> </div> |
Creating New Pages
Creating a new page to add into your site is easy. Create another new Text File (File > New > Text Document), put in your own custom content then save the file into the web folder making sure to give it a new name such as page2.html
After you have done that you can then simply edit your main website template (Applications > Internet > Site Editor) and add the link to the new page into the menu portion of your template.
To link the new page, you need to append ?p=MYPAGENAME onto the URL where p is the variable container and MYPAGENAME is the new file you created in the web folder (without the .html on it!)
Below is an example. Be sure to replace YOURIP with your actual ingame IP Address.
<html> <head> <title></title> </head> <body> <!-- Begin Menu --> <div align="center"> <a href="YOURIP">Home</a> <a href="YOURIP?p=page2">Page 2</a> </div> <br /><br /> <!-- End Menu --> <?content?> </body> </html> |
Dllfile 16:03, 28 May 2009 (UTC)
