Jump to content
xisto Community
Joshthegreat

<? Include ?> <iframe/> This could save me tons of time

Recommended Posts

Does anyone know if it is possible to target links into an area using the include tag? Because I don't want to use an iframe. So I only need one page and all the links would appear where the php include tag is.This would be super helpfull if anyone could explain if it was possible, and if so how to do it, or if not possible, any alternate codes that would to the same job, excluding the iframe and the regular frame. Thanks.

Share this post


Link to post
Share on other sites

the include FUNCTION is not an HTML tag and cannot be changed once it is downloaded by the browser. This is because the include function is a SERVER SIDE script meaning it is run by the server and replaced with whatever file you put in the include function. That include function is replaced and the browser (user) never sees the code.

The only way to change the file included in the function is to load another page. You can do this with URL variables.

example: http://ww38.yoursite.com/index.php?load=page1.html
http://forums.xisto.com/no_longer_exists/

in your index.php file you have the code: <?php include($load); "> This will load whatever page you put after the load= in your url. So when you create a link, just use the above url and it will update.

Share this post


Link to post
Share on other sites

I don't understand at all... maybe what I have at the moment is fine. I just have to change part of the table for all my content pages. No worry though. Thanks for your help.

Share this post


Link to post
Share on other sites

I'm not sure I entirely understand what you're saying, but what if you made a table or something similar then included the stuff in there?

<table>  <tr>   <td>    something   </td>   <td>    <?php include 'file.ext'; ?>   </td>etc...

Share this post


Link to post
Share on other sites

I know how to do that. All I'm asking is...Is it possible to use the include code like an iframe, meaning that you can target files to appear in the place of the include code instead of just one stuck file there. If you know what I mean...

Share this post


Link to post
Share on other sites

If my understand is right, I suggest you using javascript :D .The same as "toggle menu" --> onClick="this.style.display=none" -- for hide your page instantly.--> onClick="this.style.display='' " -- show your page.or use functionfunction toggle_page(page) { if (page == 1) { p1.style.display=""; p2.style.display="none"; } else { p1.style.display="none"; p2.style.display=""; }}<a href=# onClick="toggle_page(1)">show page1</a> | <a href=# onClick="toggle_page(2)">show page2</a><div id=p1><? include("page1.php");?></div><div id=p2 style="display: none"><? include("page2.php");?></div>// something like that.// and hope, will be right in your mind :) .

Share this post


Link to post
Share on other sites

i don;t don't know how the coding might go but why dont you use the <div> tags to seperate everything and then create navagation menu from thier that would make sense.

Share this post


Link to post
Share on other sites

Thanks nancmu, but I just had an idea. Well, not so much of an idea, but a quesiton at least.

 

is what no9t9 said basically the equvilant (below)? And if it is could someone please tell me how all of that works? Thanks.

http://ww38.yoursite.com/index.php?load=page1.html.

 

Basically what I want is the effect of an iframe, but without using one.

Share this post


Link to post
Share on other sites

the way i understood your request was that you are trying to use one page something like a template and load the content into an iframe. Except that you don't want to use iframes but instead you want to use the php include function.

 

so, what I told you to do is exactly that.

 

basically if you use URLs with variables like this

http://ww38.yoursite.com/index.php?load=contentpage.html

you can get the same effect.

 

in your index.php file you create the template for your site. basically everything that doesn't change on your site, like navigation, backgorund, etc. then you create your content (the stuff that would go in an iframe) in a file called contentpage.html (or whatever you want).

 

the structure of the index.php file will look something like this.

 

<banner HTML Code>

<Navigation HTML Code>

<?php include($load); ?>

<footer HTML Code>

 

now when you want to change the content, you simply change the $load variable.

http://ww38.yoursite.com/index.php?load=anothercontentpage.html

so for example if in your navigation you want to link to a CONTACT page, you would use :

<a href="http://ww38.yoursite.com/index.php?load=contact.html">Contact</a>

 

this will not change any of your banner, navigation, footer HTML but will update the CONTENT area with your contact page.

 

BTW, using javascript for loading page content is not a good idea because some people disable javascript and if they do, your page will be completely useless.

PHP is the way to go.

Share this post


Link to post
Share on other sites

THANKYOU THANKYOU THANKYOU!!!! Your getting a juicy reputation point for this! Thanks a load man. You need a medal, thanks a bunch, I didn;t really understand what you said before, but I do now. Thanks loads man.

Share this post


Link to post
Share on other sites

your url does not have the ?load=whatever.html part. This means that the include($load); command is loading nothing which will give you an error. You need to load something.change the line <?php include($load); ?> to<?php if ($load!="") include($load); ?>this new line will basically only load content IF you have specified it in the URL. If there is no ?load=whatever.html, you will simply get a nothing in the content area.if you want you can add HTML code there instead of leaving it blank.<?php if($load!="") include($load);else { ?><YOUR OWN HTML CODE><?php } ?>With the above code, if $load is not specified in the URL, it will display <YOUR OWN HTML CODE>adding one more thing,<?php if($load!="" && file_exists($load)) include($load);else { ?><YOUR OWN HTML CODE><?php } ?>this checks that $load is specified in the URL and also checks to see if what you specified exists. If not, it displays <YOUR OWN HTML CODE>

Share this post


Link to post
Share on other sites

Try to use this code I've made some months ago:

<?if(!$area) // If the area is not specified$area= 'main'; // go to the main pageif(strstr($area,"//") || strstr($area,"\/")) // If someone try to hack the sistemdie("The page you request was not found on this server."); // Stop allif(!file_exists("$area.html")) // If the page does not existsdie("The page you request was not found on this server."); // stop all and send an error messageelse // if it doesinclude("$area.html"); // include the specified page?>

Put this code where you want the "iframe", and the main page will be called main.html. Hope it helped you :)

Share this post


Link to post
Share on other sites

yes hacking is an issue and I also have used code to check for slashes, etc.I made a webpage using similar method. BAsically one template file which loads content a conent file. I find that this is not the best way to layout a site. I find it is better to include the layout from a file rather than the content.basically like thisinclude banner.html;include navigation.html;<content code here>include footer.html;I think this method is actually better because each page is easier to customize.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | 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.