Log in

View Full Version : Resolved A way to swap out content on a particular spot, without leaving the current page?



evanmiller2007
05-14-2009, 12:29 AM
I hope I'm explaining this right. I've looked through the site and I can't find anything that looks like it will work. I think that this is probably a pretty simple thing to do, but I was wondering if someone could help point me in the right direction.

Here is the page I'm working on (most of it is just a placeholder image)

http://www.webworkscorp.com/h3tg/interiorpage/

The site I'm working on is going to have about 50 pages or so. The client I'm working for seems to be very indecisive, so I'm expecting them to change pages around and crap a lot. So, I'm trying to avoid having to redo all the menu links on all 40 pages every time he wants to add another page. Essentially what I want to come out with is something kind of like frames, but more elegant and not so 1996.

What I'm hoping for, is a way to just make one page with the navigation and menu on it, and then a big blank area where the image and all the text will go. The image and the text will all be in an html file of its own, and when you click a link on the menu it will swap out the contents of the big blank area with whichever html file the view is calling up. It needs to work for the menu i have to the right, and also for dropdown menus above (which aren't implemented in the example I gave -yet).

Is there an good, easy and compatible way to do this? My client mentioned implementing some kind of Content Management System, but to be honest I'm a little new to all this CSS and JS stuff and I want to keep it as simple as possible.

Any advice would be appreciated! One thing to keep in mind, the solution must be very flexible- i need to be able to keep the menu on the left the way it is, and have drop downs above.

I'm open to any kind of solution! Throw em at me.

Thanks!

Medyman
05-14-2009, 12:59 AM
http://dynamicdrive.com/dynamicindex17/ajaxcontent.htm

This technique has it's drawbacks, though. It's important that you understand them. It sounds like your client's suggestion of a CMS is appropriate. No matter what you do, you're not going to be able to make a 50-page site "simple". Add to that the fact that the client will be changing things. That just seems like a recipe for disaster for me. A CMS would actually be simpler, in this case (IMO).

xiofire
05-14-2009, 01:56 AM
Why not use PHP?


<?php
if($_GET['page=OMG']; {
?>
Some html...
<?php
}
?>

Output URL:

../page.php?page=OMG

evanmiller2007
05-14-2009, 02:35 AM
thank you both for your quick responses.

@Medyman: This looks like it will work. You mentioned that there are some drawbacks to using this method. Could you possibly elaborate a bit, or point me in the direction of some information of these drawbacks? I don't see anything on the script's page that seems that bad. Am I missing something?

-edit: i looked up "Ajax" on wikipedia and you are right, it's not worth the drawbacks.

I spent some time researching CMS's, mainly one called "CMS Made Simple". I tried to go through an installation but this stuff is way over my head. I'm not super experienced with this type of stuff- SSH, cPanel, Databases... this stuff is all Greek to me. Plus, I don't think any of my current hosting packages support this kind of stuff, so I can't even test it out. I'm sure if I knew how to use it, CMS would be a lot easier but for now I can't get past step 3 in the installation process. I've got to start putting this site together as soon as tomorrow, so I don't have a lot of time to figure this stuff out.



@xiofire: You lost me... any chance you have a link to a more detailed walkthrough of how this stuff works? I wouldn't mind checking it out as a backup.

like I said, thanks a ton for all the help. I've only really been doing web design for a few months now, and I just made the switch from tables to CSS last week so please bear with me a little bit :)

xiofire
05-14-2009, 10:58 AM
Well basically, what I posted enables you to have multiple pages inside of one page.
I could build a whole (not-so interactive) site with one PHP file, quick example:

<?php
session_start();
?>
<html>
<head>
<title>xiofire's one file site</title>
</head>
<body>
<?php
if($_GET['page=page1']); {
?>
Here is my first page!
<?php
}
?>
<?php
elseif($_GET['page=page2']); {
?>
Here is my second page!
<?php
}
?>
Welcome, <?=$_SESSION['username']?><br />
Here is my index page, choose a page to go to below!<br />
<ul>
<li><a href="../index.php?page=page1">Page 1</a></li>
<li><a href="../index.php?page=page2">Page 2</a></li>
</ul>
</body>
</html>

There, 3 pages in one file. You can also through in CSS, PHP, etc...
This is how most software installation is set up.
Look at the code above, it should explain itself. :)

Medyman
05-14-2009, 02:12 PM
@evanmiller

I just did a quick Google search for CMS Made Simple. From the looks of it, it's not that simple at all. The general rule of thumb is that if they need to add 'simple' to their name, there is probably something up there.

My personal recommendation would be to use ExpressionEngine. There is both a commercial and a free, open source product. The free 'core' version should suit your needs just fine. The great thing about ExpressionEngine is that there is a vibrant community ready to help you should you get stuck.

Depending on the structure of your site, you could also use WordPress. The same argument applies there. It's been used by a lot of people and there are ton of resources available and a ton of people to help.

There are thousands of CMS software out there, but most of them are complete junk.

@xiofire
That technique works if you're creating a small site. The OP stated that his site is at least 50 pages. Having 50 pages worth of markup in one file would be fairly horrendous code.

Even using PHP, there are more flexible ways to do it. Using includes, for example.

evanmiller2007
05-14-2009, 02:49 PM
thanks for all the help, guys! i think I figured out a good solution- I'm just going to use Dreamweaver to make the site into a template, so that I can make changes to the navigation and just apply it to all pages. I think this will work pretty well for me.

Like I said, thanks a ton. I really appreciate the advice.