Log in

View Full Version : Creating User Control In PHP (.ASCX)



tomyknoker
03-13-2007, 01:12 AM
Hi all,

I was looking into a ASP .NET site which on all the pages had a menu down the side, and controlled other pages. I looked for the file and found out it was called nav.ascx. Apparently it's a user control file, can you do something like this with PHP?

thetestingsite
03-13-2007, 01:14 AM
Try something like:



<?php

include('path/to/your.file');

?>


The above will include the contents of the file (in this case "your.file") into the page that you place the above code.

Hope this is what you mean.

tomyknoker
03-13-2007, 01:59 AM
Oh yea so I could just set up a nav.php file or something? And add that into the pages?

thetestingsite
03-13-2007, 02:02 AM
Exactly right, that is if that's what you were talking about in your first post. If not, you may have to be a little clearer (probably not perfect grammer, but oh well) on what it is you want to do.

Hope this helps.

tomyknoker
03-13-2007, 02:04 AM
Well I mean ASP creates a special fancy file, but I guess php just does it more simpler, just by adding in whatever .php file you want to the page...

Twey
03-13-2007, 08:35 PM
ASP.NET interferes with the HTML a lot and tries to smooth over the difference between client-side code and server-side code, which is a maintenence nightmare. PHP doesn't do any of this. If you want to write HTML, you write HTML: it doesn't create widgets or anything like that. This approach makes it slower going sometimes, but in the end tends to increase flexibility.

tomyknoker
03-13-2007, 09:18 PM
The only thing I liked about it was it sat on the left hand side and all the content displayed on the right... The nav.php file I include on all MY pages, makes all the info display below it... Is it just a HTML thing that I have to play with? I am a total newbie at php, adding the HTML is confusing me a bit...

Twey
03-13-2007, 10:02 PM
Yup, that's purely an HTML/CSS issue. Examine the HTML generated by the ASP.NET script to get an idea of how to replicate it.