Xtremax - Web Design

03 Mar, 2009

.NET Masterpages in PHP with JQuery

Posted by: Mr Otter In: .NET| javascript| jquery

I was struggling to do some prototyping for a new client.  I needed to create a lot of static pages.. and like all static pages, they have a header panel, a side menu panel, footer, and finally the content pane.

Well, if I was to do it in php, the usual method will be something through the use of include files, i.e.

<? require_once(‘header.php’) ?>

<div id=”content”>

Blah blah blah

</div>

<? require_once(‘footer.php’) ?>

This does not really look too ugly, until you look into header.php itself and you see a half rendered webpage that looks really awful in your favourite dreamweaver editor… as the html structure is entirely corrupted in such a partitioning.

A neater way is to use the jQuery approach whereby all you need is:

<? require_once(‘template.php’) ?>

<div id=”content”>

Blah blah blah

</div>

in the main content page.  The trick lies in putting the content div into a contentContainer div in the template.php (your template.php must have a contentContainer div to work…) and then hiding the content div.

$(”#contentContainer”).html($(”#content”).html());
$(”#content”).hide();

Now.. doesn’t your PHP codes look like its using the ASP.NET masterpage framework?  And the beautiful thing is.. your template.php looks like a perfectly well formatted template in dreamweaver… 





Bookmark and Share

1 Response to ".NET Masterpages in PHP with JQuery"

1 | louis vuitton for sale

July 7th, 2010 at 10:34 am

Avatar

Well , the view of the passage is totally correct ,your details is really reasonable and you guy give us new balance 1300 valuable informative post, I totally agree the standpoint of upstairs. I often surfing on this forum when I m free and I find there are so much good information we can learn in this forum!

Comment Form

Xtremax Web Design Portfolio

    Opera Estate Primary SchoolNational Association of Travel Agents SingaporeFUMIYAMA CORPORATIONEngineering Education PortalBOON HI-TECH SUPERSTORESingapore Tourism Board

About Xtremax

This is all about a group of hard-core web developers who go about rambling about their daily efforts to make the internet world a better and more accessible place.