0

i'm trying to avoid iFrames on the developing of a website. I've tried many sample codes but nothing seems to work. if you could tell me exactly where and how to put the code i would appreciate :)

Thanks in advance.

PS: everything is ok with the server i'm working it.

<div id="menuWork">
            <h1>Web:</h1>
                <ul>

            <!--links to dynamic content -->

                    <li><a href=">&#62;REN</a></li>
                    <li><a href="" id="" >&#62;Vasco Gaspar</a></li>
                    <li><a href="">&#62;GF Guitars</a></li>
                </ul>

             <h1>App's:</h1>
                <ul>
                    <li><a href="">&#62;DesignerTools</a></li>
                    <li><a href="">&#62;Artec21</a></li>
                </ul>

             <h1>Print:</h1>
                <ul>
                    <li><a href="">&#62;Self-Promoting Poster</a></li>
                    <li><a href="">&#62;Another Day Will Come</a></li>
                    <li><a href="">&#62;Qiasmo</a></li>
                    <li><a href="">&#62;Logo</a></li>

                </ul>

             <h1>Other:</h1>
                <ul>
                    <li><a href="">&#62;Chapéu é o nome (video)</a></li>
                    <li><a href="">&#62;Papá Wrestling <br />(video-Special FX)</a></li>                    
          </div><!-- #menuWork -->





        <div id="content">

        <!-- Content Area where dynamic content would appear -->



        </div>
vascogaspar
  • 103
  • 2
  • 12

4 Answers4

1

You need to use AJAX to achieve that. You create a PHP script to create the content and you add a javascript action on clicked items. You add an id attribute for each link and create a js function like (here using jQuery AJAX):

$('#link1').click(function() {
 $.ajax({
 url: "generate_content1.php",
 success: function(data){
  $('#content').html(data);
  }
 });
});
Mika Andrianarijaona
  • 1,619
  • 17
  • 29
  • i've already mounted it in ajax but the problem is that the URL don't change. it bothers me in SEO aspects. know any solution? – vascogaspar Sep 20 '11 at 12:50
  • If you want to change the URL without reloading the page, try to look at [this thread](http://stackoverflow.com/questions/824349/modify-the-url-without-reloading-the-page) – Mika Andrianarijaona Sep 20 '11 at 12:57
1

The simplest way is something like what one user commented on your question. Make the server include particular files based on the query string value. Those include files will contain your content and every time a link is clicked the whole page will be refreshed with the dynamic content. Eg:

<?php
    $page = $_REQUEST['p'];
    $valid_pages = array('first-page-name', 'second-page-name', 'third-page-name', '...etc.');
    switch ($page) {
        case 'first-page-name':
            $title = "First Page Name";
            break;
        case 'second-page-name':
            $title = "Second Page Name";
            break;
        case 'third-page-name':
            $title = "Third Page Name";
            break;
        default:
            $title = "Some Default Title For Your Site";
    }
?><!DOCTYPE html>
<html>
    <head>
        <title><?php echo $title; ?></title>
    </head>
    <body>
        <div id="menuWork">
        <h1>Web:</h1>
            <ul>

        <!--links to dynamic content -->

                <li><a href="?p=first-page-name">&#62;REN</a></li>
                <li><a href="?p=second-page-name">&#62;Vasco Gaspar</a></li>
                <li><a href="?p=third-page-name">&#62;GF Guitars</a></li>
            </ul>

         <h1>App's:</h1>
            <ul>
                <li><a href="">&#62;DesignerTools</a></li>
                <li><a href="">&#62;Artec21</a></li>
            </ul>

         <h1>Print:</h1>
            <ul>
                <li><a href="">&#62;Self-Promoting Poster</a></li>
                <li><a href="">&#62;Another Day Will Come</a></li>
                <li><a href="">&#62;Qiasmo</a></li>
                <li><a href="">&#62;Logo</a></li>

            </ul>

         <h1>Other:</h1>
            <ul>
                <li><a href="">&#62;Chapéu é o nome (video)</a></li>
                <li><a href="">&#62;Papá Wrestling <br />(video-Special FX)</a></li>                    
        </div><!-- #menuWork -->

        <div id="content">
<?php   if (in_array($page, $valid_pages)) {
            include('pages/' . $page . '.php');
        } else { ?>
            <h2>Page not found</h2>
            <p>The page you requested was not found on this server.</p>
<?php   } ?>
        </div>
    </body>
</html>

Then you would place your content for each page in a file in the /pages/ folder of your site matching the string that is passed in the URL via p=<your_filename_here>. (eg: 'first-page-name' would load /pages/first-page-name.php) I have included an array of permitted filenames so as to prevent attackers from including arbitrary files. This is a very basic example. Hopefully you can learn from it and expand upon it.

sholsinger
  • 3,028
  • 2
  • 23
  • 40
  • can't make it work. only the error message appears. i really don't see what i am doing wrong. files with content in the pages folder all called in the code. can you do a commented version to make sure i'm not doing nothing wrong? Thanks – vascogaspar Sep 20 '11 at 14:01
0

Use AJAX , With Ajax, web applications can send data to, and retrieve data from, a server asynchronously (in the background)

Aman Agarwal
  • 727
  • 6
  • 15
  • is it the best option in terms of SEO when compared to this method? – vascogaspar Sep 20 '11 at 12:45
  • Yes..if you talking in terms of SEO..Search engine give different rank on different query string with the same url for eg.. http://example.com?q=query1 http://example.com?q=query2 has the different rank .....thought the site site is same – Aman Agarwal Sep 20 '11 at 12:48
  • what can i do if i want to link from other page to a specific link on this page using AJAX? – vascogaspar Sep 20 '11 at 13:08
  • @CosmicSans can you please elaborate it ... I unable to understand what you asking .. – Aman Agarwal Sep 20 '11 at 13:10
  • sorry. imagine i am at the "home" page and i want to link to the "work" page (the page i'm working on AJAX). how can i get a specific path to a specific content since the URL is the same for every content? did i make that clear? sorry for bad english phrase construction. – vascogaspar Sep 20 '11 at 14:04
0

<li><a href="<?php echo "/?page=designer-tools" ?>">&#62;DesignerTools</a></li>

Maybe something like this? Your question is pretty vague.

Chris G.
  • 3,963
  • 2
  • 21
  • 40