Scripts
NL-GenericPages
-
NL-GenericPages
Released on January 8, 2004, Last Updated on April 20, 2008
Written by
Sasha
Added by Sasha (view more by Sasha)
NL-GenericPages explains how to set up a generic page that is the same on all your sites except for a few variables that you define yourself. For example, if you run several fanlistings or cliques, the Rules page will look pretty much the same for all of them, except for maybe the title and the URL of the site. This explains how to set up the same page to be included in multiple sites, but with different site titles, URLs or whatever else you require. Again, this one is very easy.
About
Set up one page to be included in multiple sites, where the only difference will be a few variables defined by you. This is very useful is you run several similar sites (like a bunch of fanlistings) where a couple of pages are always the same except for the site name, the url etc. This script is currently in use on all of my fanlistings for the Rules and the About pages.
Install
I’ll show you how to do this by example. Say you own loads of fanlistings (like I do), and your Rules pages always looks something like this:
- You must be a fan of [SUBJECT]
- You must fill in your country on the Join Form
- If you own a website, you must provide a link back to [URL]. You may use a text link or one of the codes I created.
- If you own a porn/hate/offensive site, I will not link you. I will add you to the member list, but I won’t add your URL.
This page looks the same on all my fanlistings, except for [SUBJECT] and [URL]. Instead of having to copy and paste this code into all my Rules pages for all my fanlistings, I will only create this page once.
Open up Notepad/Editpad/your preferred HTML coding editor. Create a blank page and save it as whatever.php (replace whatever with your own page name). For this example, I’ll assume you named the page rules.php and that you will upload it to the root directory of your website.
Copy and paste the HTML from your Rules page (or any other page you’re doing this with) into the .php file. Now look at the bits that will be different for each site. In the example above, that would be [SUBJECT] and [URL]. Replace those bits with the following: <?php echo $subject; ?> and <?php echo $url; ?>. The <?php opens the PHP tag, the echo part says that a variable should be displayed, and the dollar sign lets the php script know that what follows is a variable. You can change the “subject” and “url” to anything you want, and you can put as many variables in the .php file as you want. Just make sure the coding around it remains intact.
Now open up the pages you want to include this file into. Remove the HTML that you copied into the rules.php file, and insert the following:
<?php //Put the variables that you have in the .php script below, with the right values for this page. $subject = "BlaBlaBla"; $url = "http://blabla.site.com"; //This will include the .php file. Be sure to replace "yoursite.com" with your own site address, //and "rules" with whatever you named your .php page include "rules.php"; ?>
Read the code carefully and look for the lines that start with //. They are comments, and explain what and where you need to change something. If you have any problems with it, or any questions about this script, please feel free to leave a message at the forums.
Please note that the page you are inserting this code into has to have a .php extension, otherwise it won’t work!!