Jump to content

Need help making website more efficient!


danielr280

Recommended Posts

Hey, I'm new to PHP, but I've used HTML for awhile.  I was asked to do a redesign for my fraternity's website, most of which was coded in PHP.  Rather than start from scratch, I decided to go with a combination of HTML and PHP, using existing code when possible.  Right now, the site uses "require" commands to include the header and footer files (which contain the menu and style stuff), and each page is a separate php file (each of which includes the header and footer).  However, loading a new page after clicking each menu link is less efficient than I would like.  I know it's possible to make dynamic content (arrays?) using PHP, and having all the code for the site in one big php file, but I don't know how to do this.

 

Here's the site now:

www.zete.org

 

I also tried using an iframe, but this proved to be even slower.

Is there any way besides frames that I could have the menu at the top change the content in the middle of the page, without having to reload everything?  Thanks in advance!

Link to comment
https://forums.phpfreaks.com/topic/38108-need-help-making-website-more-efficient/
Share on other sites

you could use my "modules" system.

 

Place include('modules.php'); where you want your content to be displayed in the index.php file. Make sure you have the modules.php file in the same place as the index.php. Also, create a folder named "modules" and in the modules folder create a folder for your home page. For instance, inside the modules folder your home folder (with index.php inside that with your homepage content)...(the code below) $modules = "news" would be $modules = "home";. index.php, modules.php and modules folder need to be in the same directory. If you don't understand something let me know and i'll try to explain the best i can. I hope this helps.

 

modules.php code:

 

<?php

if($_GET['modules']) {

$modules = $_GET['modules'];

}
else {

$modules = "news"; 

}

include "./modules/$modules/index.php";

?>

 

Also, for instance, say your folders inside modules folder are home, news, contact. Your links for these would be:

 

The link to the home folder inside the modules folder would be index.php?modules=home

The link to the news folder inside the modules folder would be index.php?modules=news

The link to the contact folder inside the modules folder would be index.php?modules=contact

 

**the php files in the folders in the modules folder HAS to be named the same as the php file in this line:

 

include "./modules/$modules/index.php";

 

in can be changed, just make sure they are named the same as the php file in the line above.

 

here is my index.php code:

 

echo "<table align=\"center\" valign=\"top\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" height=\"100%\">";

echo "<tr>";
echo "<td width=\"15\" height=\"80%\" background=\"" . $ltable . "\"></td>";
echo "<td valign=\"top\" width=\"970\" height=\"80%\" align=\"center\" background=\"" . $tbbg . "\">";

echo "<!--- Module Starts Here -->";

echo "<table align=\"center\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" height=\"20%\" border=\"0\" bordercolor=\"#202020\">";
echo "<tr>";
echo "<td colspan=\"3\" width=\"100%\" height=\"5\"></td>";
echo "</tr>";
echo "<tr>";
echo "<td align=\"center\" valign=\"top\" width=\"17%\" height=\"450\">";

echo "<!--- This is where the module starts. -->";

include('include/lmenu.php');

echo "<!--- This is where the module ends. -->";

echo "</td>";

echo "<td align=\"center\" valign=\"top\" width=\"66%\" height=\"450\">";

echo "<!--- This is where the module starts. -->";

include('modules.php');

echo "<!--- This is where the module ends. -->";

echo "</td>";

echo "<td align=\"center\" valign=\"top\" width=\"17%\" height=\"450\">";

echo "<!--- This is where the module starts. -->";

include('include/rmenu.php');

echo "<!--- This is where the module ends. -->";

echo "</td>";

echo "</tr>";
echo "</table>";

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.