tweaker
01-18-2007, 04:12 PM
I have a php file and an html file I want to put in a frame. The php file is item1.php and the html file is item2.html. What's the easiest way to do this?
|
Click to See Complete Forum and Search --> : Simple Frame question tweaker 01-18-2007, 04:12 PM I have a php file and an html file I want to put in a frame. The php file is item1.php and the html file is item2.html. What's the easiest way to do this? Sheldon 01-18-2007, 07:47 PM why frames? There outdated. Can you explain more on what you are trying to do? Dranoweb 01-18-2007, 09:38 PM I agree, frames ARE outdated, but some of us do not know many other ways to do this. Like me for instance, however I have made a point to get off my rear end and learn something better, not that anyone replies to my posts to maybe hint at what direction I should go. NightShift58 01-18-2007, 09:46 PM To simulate a frame, you would use a PHP script (item1.php) as the control script, set up your layout either with <table> or - before everyone screams - with CSS. In the area that would normally correspond to the frame, your PHP script then issues an include instruction to include whatever file needs to be included (in this case, item2.html). It may seem a bit more of a hassle to do it this way, but even in the short run, you'll find that you'll have more control over the process. Of course, the included file need not be an HTML file and that gives you more opportunities to apply PHP across what would have been 2 frames. Sheldon 01-18-2007, 09:57 PM php.net/include is a good alt to frames. NightShift58 01-18-2007, 10:05 PM I guess AJAX would also be an alternative but at this point in the OP's PHP career, it may introduce an unwarranted level of complexity. And, unless you were holding a gun to my head, I wouldn't touch it. Dranoweb 01-19-2007, 03:38 AM From my point of view it seems like an idea that may blend with my current arrangement, without having to restructure and rewrite everything. Will give it a try and see how I go. Though I will have to read up a little more on php now. netbuddy 01-19-2007, 06:55 AM why frames? There outdated. Can you explain more on what you are trying to do? Frames are not outdated, what ever makes you think that? Frames are a very useful way of being able to stitch several components together to make a whole page which ONLY changes the content that NEEDS CHANGING and NOT the whole page. php and frames work together just like javascript and asp and all the other wonderful methods of producing a web page. ALL the Domain name providers "Mask" or "Cloak" using frames or allow you to forward which unlike masking the site will show up the site IP or DNS name, cloaked and your URL name is displayed. Frames are outdated, in deed, whatever next! In answer to the question, you would need to make up a framset, which is a HTML page or it can be a php page, you then within the framset tell the individual frames what pages to load into them. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Your Page title here</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link rel="stylesheet" type="text/css" href="mystyle.css"> </head> <frameset rows="80,30,*,16" cols="*" frameborder="no" border="0"> <frame src="head.html" name="head" noresize scrolling="no" > <frame src="menu.html" name="menu" noresize scrolling="no"> <frame src="main.html" name="main" noresize scrolling="auto"> <frame src="foot.html" name="foot" noresize scrolling="no"> <noframes> <body onmouseover="window.status='';return true"> <p><font color="#FFFFFF" size="6">NO FRAMES -- Time for you to update your Browser as it does not support frames.</font></p> <p>please visit <a href="http://www.microsoft.com">www.microsoft.com</a> or your web browser vendors site, thank you.</p> </body> </noframes> </frameset> </html> Is an example of a frameset I use for my girlfriends website, the frameset is set up like so. rows="80,30,*,16" cols="*" where rows tells the bowser to devote, 80pixels for one frame, 30pixels for the next, * means anything left over == 100% and 16 pixels for the foot of the page. It makes a 4 page split with the 3rd pane having auto scroll as it is the mai dispay area. cols tells the browser that the colum is 100% of the width. things can get a bit complicated whren you start to nest framessets within framsets, but theirs nothing from one frameset window calling another page thats a frameset. . Dranoweb 01-19-2007, 10:25 AM Well My site iw www.dranoweb.com and I use frames for it, however I am receiveing complaints about the load time. Iwould attribute it to the two java applets i use for the logo and menu, and I am working on optimising those for better speed. However it has been suggested by a friend of mine who does feelance webdesign, that I should steer away from frames. I welcome any suggestions however. The topic of frames, the more i read, is starting so seem alot like the "Ford vs Holden" argument. they are both cars, and both do their job well, and in today's market they have very close performance stats. (and no don't start arguing about this - go to MY forums if you want to) tweaker 01-19-2007, 01:06 PM Why I'm wanting to do a frame for this is really simple. I want to build a website so that on the top frame (1 pix tall, black) has a windows media player playing music. The bottom part is a page that displays the last ten songs played. The radio page is http://www.mtgopre.com/radio/radio.html. The list page is http://www.mtgopre.com/radio/playing_test.php. I want to combine so that I can build a website that'll play the music and let you surf the site without having to keep the music restarting every page you go to. This is why I was thinking of a simple frame. The HTML page works great however the PHP page doesn't work. Tweaker netbuddy 01-19-2007, 03:01 PM As a surfer, even on an 8Meg line, I get annoyed with website that take allong time to load and for silly little things like an image enlargement, I dont see the need to load a whole new page that looks the same as the last page yet less than 30% of the content changed and usually the main display area, so using frames on sites that ues nice graphics to reduce the load times of pages, not having to reload the logo and banners over and over again makes perfect sense to me. What I dont understand is why people go out frame bashing, especially when something is in use today that appears to be dated is often not the case. I prefer to split a page into a set of frames, one to hold the banner, another for the menu and another for a side bar if needed and one for the foot of the page and the display page, which is the page that does all the changing. Framesets are very useful for web pages that have very tight traffic allowances, some free hosts have a limit to which they lock your website out if you exceed your traffic allowance, yet simple measures you can implement to produce a nice semi-graphic site with display pages that have minimal images, no background image just a plain one to match the surrounding frames that is mainly formatted text, you soon take a 45kb page that loads up 700kb of images per page load and you modify the site to load into frames the static bits and an index page, your load once ar 700kb + 45kb page but each subsequent page change will be 4 or 5kb depending on amount of text to display and not 745kb per page load, after say 10 pages, one site will use up 7450kb and the other 795kb, a huge difference. So now tell me frames are redundant and useless. NightShift58 01-19-2007, 03:21 PM ...not having to reload the logo and banners over and over again makes perfect sense to me.Most browsers deal with that very efficiently. I prefer to split a page into a set of frames...Same basic techniques with PHP include... except that PHP gives you more - and better - control. Framesets are very useful for web pages that have very tight traffic allowances ... a huge difference.Take a look at your server access log files and you'll see that that's not quite the way things happen in terms of real traffic. So now tell me frames are redundant and useless.And so I tell you: it isn't a sin to use frames but there smarter ways to get the job done, with better control over the display, fewer headaches when coding interactive features, implementing security checks, etc... netbuddy 01-19-2007, 04:12 PM Your missing the point. You can use PHP in frames, PHP to make the frames, PHP to do all of it, except EVERYONE cant comprehend what IM trying to relay to you all, the amount of data traffic, the surrounding frames do not change therefore you limit having to load those graphics again and again the only portion of a frameset to change is the page that has been requested to be replaced which can be controlled by another frame if needed. When size matters, splitting a website into a frameset is the right thing to do, if your fortunate to have no worries about allowances and dont care that your audiance viewing your site has buggered off to watch an episode of corrie because your site takes too long to load, it really makes me wonder if people really do think about who they are targeting. Fact is, most of the world is still on dialup, by dialup IM talking 56k dialup or 64k Narrowband Dialup, allot of the world is still behind on basic internet technology and in allot of cases, the urban areas become saturated before companys think about extending the arms of broadband to more rural areas so until the exchanges are upgrades, ADSL or Braodband becomes available, most of the world has to suffer the pain of having to sit and wait for a whole page to refresh when only 30% or less needed to be updated. I dont know how much more simpler I can put it, when designing a website, you have to take more into consideration than the design and coding, the content that you deliver needs to be properly treated, images and photos that are not net optermised will eat up allot of traffic. When I went to college and studied web design as one of my subjects, we were taught that a well produced site will load in a couple of seconds. The average internet surfer (like me, IM not excluded) will tollerate a site for so long before moving off, especially when it takes 20 seconds to load up over an 8 meg line, I think, poor Ba*****s on 56k dialup. When I write a web pages code, it is an average of 3 to 6kb in size, scripts 1 or 2kb, images not more then 13kb for photos, 12kb colour images like logos and banners, 6-8kb for small images, 2-3kb for thumbnails and buttons. The background if used is not more than 25kb in size for a full page image. Most pages I come across are large, most are >100kb and <1meg, most pages produced by macromedia are over 1 meg, so I have to further optermise the graphics and site code, removing usless junk that the editor stuffs in. by rendering websites in this way, you make then very quick so if your host is slow, it still looks like a fast loading site, the visitors are still at your site and not leaving it because of long load times. IM sorry to rant on, but size really does matter. I know of 20 or more people that are still on a dial up service and I have had to listen to their rantings about long load times and other stuff, yes I have made those mistakes and learnt from them and found quicker ways to serve up without compromising the overall functionality of a website, I am sorry frames are a part of that but I didnt make the rules, please go and shoot the guy in thw W3C organisation who made up that rule so he could justify a pay check... NightShift58 01-19-2007, 04:25 PM I did say that using frames is not a sin, in my opinion - at least not a cardinal sin. But do me a favor: set up a frameset with frames and one with simulated frames (using include method and layout). Run both and then look at your server log files. You'll find that the graphics were not downloaded twice. The browser checked with the server, the server said "No change" and the image in the browser cache was used again. So no additional waiting there... mergemedia 01-19-2007, 04:56 PM certain browsers don't deal with frames very well, and crawlers don't like them either. I'd recommend the php include :) Dranoweb 01-19-2007, 09:52 PM Well having been a self taught developer, (If I may assume that title) I chose frames early on as I had large graphics on the main page, and wanted the speed and ease of simply loading up the information that should change, not the java applets etc that take time and bandwidth to reload. Originally I was on a very limited bandwidth, now I have 1000gb a month (thanks to ixwebhosting(dot)com) So that isnt so much of an issue. However - aside from all the arguing, I find frames easy to work with and very usefull... HOWEVER... I am sure there are better ways to do this, as I have found crawlers do not pick up information on my page, or at least if they do, it takes in excess of 4 moths to show it, as there is still no sign of it in the 75 search engines I submitted my site to. This is an issue for me. What I need to know is HOW. Can someone here explain to me in a few steps (need not be simple) HOW to lay out content on a page, while preventing the large components from reloading while an embedded html file changes on command from a link. (java applet) I should add - with a crawler friendly method. NightShift58 01-20-2007, 02:08 AM A typcial "frameset" consisting of a header, menu, content area and footer, could look like this - using a table as an example but use CSS once you have the hang of it:<?php $content_page = $_GET[$page]; print "<table>"; print "<tr>"; print "<td colspan='2'>"; include "header.php"; print "</td>"; print "</tr>"; print "<tr>"; print "<td>"; include "menu.php"; print "</td>"; print "<td>"; include $content_page; print "</td>"; print "</tr>"; print "<tr>"; print "<td colspan='2'>"; include "footer.php"; print "</td>"; print "</tr>"; print "</table>"; ?>This is a skeleton. You'll need to add some safety nets for $_GET['page'] to make sure you're only showing existing pages that are authorized, etc,but these are things you would have to do even if using framesets (dynamically). Dranoweb 01-20-2007, 06:26 AM Ok that doesn't look too bad, I'll give it a go later, just finished doing some optimizing, and managed to knock 5 seconds of my page loading time, and have it back to about 3.9 on a 512k connection. It was the java applets slowigng things down, but a new way of arranging things would be good. netbuddy 01-22-2007, 03:24 AM I did say that using frames is not a sin, in my opinion - at least not a cardinal sin. But do me a favor: set up a frameset with frames and one with simulated frames (using include method and layout). Run both and then look at your server log files. You'll find that the graphics were not downloaded twice. The browser checked with the server, the server said "No change" and the image in the browser cache was used again. So no additional waiting there... Entirely down to your configuration, in my experience, web hosts are not too concerned with the number of times an image is sent to the same IP address, they are only intre3sted in making more money out of you, so it is in their best intrests to provide this traffic. PHP is dynamic and as my old college tutor put it, until it exists, it cant be cached so if it does not yet exist, the browser cannot reuse ANY graphics. We actually looked at the browser cache and sure enough a few hundred of the same image had been downloaded. I suggest that you look in your browser cache before it gets deleted. NightShift58 01-22-2007, 11:47 AM Please...Take a look at your server access logs. Anything with a 304 code means "cached". Example:192.168.3.10 - - [21/Jan/2007:20:04:28 -0600] "GET /tv/hollywood_logo.gif HTTP/1.1" 304 - "http://192.168.3.2/tv/" "Mozilla/4.0 (compatible; MSIE 6.0; Window s NT 5.1; SV1; .NET CLR 1.1.4322)" netbuddy 01-24-2007, 03:12 AM Please read the opening comment, a 304 DOES not mean cached it is a responce to indicate that the state of a file has not changed, AGAIN it is down to personal settings... 304 Not Modified If the client has performed a conditional GET request and access is allowed, but the document has not been modified, the server SHOULD respond with this status code. The 304 response MUST NOT contain a message-body, and thus is always terminated by the first empty line after the header fields. The response MUST include the following header fields: - Date, unless its omission is required by section 14.18.1 If a clockless origin server obeys these rules, and proxies and clients add their own Date to any response received without one (as already specified by [RFC 2068], section 14.19), caches will operate correctly. - ETag and/or Content-Location, if the header would have been sent in a 200 response to the same request - Expires, Cache-Control, and/or Vary, if the field-value might differ from that sent in any previous response for the same variant If the conditional GET used a strong cache validator (see section 13.3.3), the response SHOULD NOT include other entity-headers. Otherwise (i.e., the conditional GET used a weak validator), the response MUST NOT include other entity-headers; this prevents inconsistencies between cached entity-bodies and updated headers. If a 304 response indicates an entity not currently cached, then the cache MUST disregard the response and repeat the request without the conditional. If a cache uses a received 304 response to update a cache entry, the cache MUST update the entry to reflect any new field values given in the response. You notice that they say WHEN its used in a CACHED situation... not that 304 is Cached, it indicates that notinhing has changed on the server. NightShift58 01-24-2007, 03:40 AM 192.168.3.10 - - [21/Jan/2007:20:04:28 -0600] "GET /tv/hollywood_logo.gif HTTP/1.1" 304 - "http://192.168.3.2/tv/" "Mozilla/4.0 (compatible; MSIE 6.0; Window s NT 5.1; SV1; .NET CLR 1.1.4322)"From the above 304 log line, can you tell how many bytes were transferred? Apache Installation -> 100% default IE7 and FF2 browsers -> 100% default and no bytes transferred on 304... So I really don't know what to tell you except to tell you that that's the way it works at my end of the stick, from what I've seen and experienced. And, reading this and other forums, one also gets to read things like "make sure you turn caching off", etc. I see nothing in the extract you posted which would refute that HTTP caching takes place. On the contrary, after looking at all the SHOULDs, MUSTs, DOs and DON'Ts, I feel that we are miles away from your initial statement, that caching never takes due to profit-minded hosting companies. All my accounts (Yahoo, Interland, Hostgator, GoDaddy, PowWeb), as well as my SuSe Linux/Apache 2.0 home servers allow caching - unless I explicitly turn it off in scripts. I do think that you are disseminating questionable facts and I hope that other readers will be able to investigate this issue on their own - but it's not worth carrying on. This was about alternatives to frames and it's degenerating into something of which I want no part. I give up. netbuddy 01-24-2007, 05:16 AM Horse for courses. You should never assume that Apache is the Be all and End all of the web server industry, what Apache do is different from the rest of the world vendors and I have tried 40 odd servers and Apache is the odd ball despite being so widely used by ISPs and people who home host. Frames are always up for a firey debate, its that "Marmite" thing, you love it or hate it, and agin its down to your personal taste and design style and it really is not the place to tell people not to use one thing over another but to make them aware of a fact, that fact being that most of the time, your browsing a website that is masked or cloaked using frames. Frames are and will still remain a valid way of presenting a web site, I use them all the time, invaluable needless to say and when you get over the problems associated with referencing other frames within your site through javascript, everything becomes childs play. NightShift58 01-24-2007, 05:26 AM Please read my previous post: I had given up. You win. I give up. White flag raised. I surrender. And unconditionally, at that... Dranoweb 02-24-2007, 11:23 PM Well this is all good and well when one is fluent with php or css - I am still only learning, and I have to teach myself. For the time being until I become more fluent, can someone lend some advice on how to prevent seperate pages from ,loading outside the frameset? I have some idea about setting one as a child of the other, but am unsure where to start with the command line. Dranoweb 02-24-2007, 11:24 PM Well seems I forgot to read page 2, Thats what I get for not logging in very often. _ disregard the above if irrelevant. Sheldon 02-24-2007, 11:50 PM You really are self minded and stupid. You think you are right and wear the sh!t out of others who you think are wrong, Yet no body is saying you are wrong, just that frames arn't the only web application that uses cache. You never took the advice of night shift 58 and looked at your logs to see that caching is involved all of the time not only when using frames. You aussies are always last to the point and slow to follow. As for "trying 40 odd servers and apache being the odd-ball" I dont no what drugs you are on. Apache is the most knowen web server there is, next would be IIS and only because its a M$ product not for it being good. Take a big breath, admit we wasted you in the cricket last week and grow up. Horse for courses. [what a w@nker] You should never assume that Apache is the Be all and End all of the web server industry, what Apache do is different from the rest of the world vendors and I have tried 40 odd servers and Apache is the odd ball despite being so widely used by ISPs and people who home host. [what are you on about? industry standard server software!!] Frames are always up for a firey debate, its that "Marmite" [only ausies and kiwis will no this one? why bring that up?]thing, you love it or hate it, and agin its down to your personal taste and design style and it really is not the place to tell people not to use one thing over another but to make them aware of a fact, that fact being that most of the time, your browsing a website that is masked or cloaked using frames. [ Remember the start of the argument, we only stated that frames ARE outdated in web standards -www.w3c.org- and offered alternatives.] Frames are and will still remain a valid way of presenting a web site, I use them all the time[i would hate to pay you to design my sites GO SEO], invaluable needless to say and when you get over the problems associated with referencing other frames within your site through javascript, everything becomes childs play.[except if frames and JS are not enabled with the users browser, you cant disable PHP, but alot of people disavble JS and frames.] Dranoweb 02-25-2007, 05:55 PM Well seems I started something way back in this topic. Now everyone in this country is being shoved in one box because 1 person has an opinion someone else dislikes. The efficiency and usability of a particular programming language, service or method is only relative to one's needs. Apache may be oddball to those who have different needs. However to those it applies to, it is probably a godsend (if you are a religious sort). But what is beyond me, is that why this warrants insults and petty bickering. GET OVER IT! webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved. |