PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, May 18, 2022

[FIXED] How to refresh partial content with new URLs?

 May 18, 2022     html, partial, url     No comments   

Issue

I want that some sections on my page to remain (like header, footer) and only the main content to change. In the same time, the URL should also change, according to the new content.

I know all about AJAX/iframes but I don't want to use them as the URL remains the same.

Take a look please at 123contactform.com. Try to play around with the left menu and notice that the main content changes and also the URL (while the header, menu, footer stays).

How is this achieved?

Thanks.


Solution

Actually the webpage you give does not only refresh its content. It may look that way, but you can see that header is still flickering aka refreshing(also if you change the content live it will change when you click a link)

There is actually a whole new page. But they use templates to create the content.

One page is a template website that calls different fractions of the webpage(ie footer, header and content). Where the content can just have an other content based on the given input.

This can just be done with php.

Template.php

include "header.php";

include $contentpage;

include "footer.php";

Where you give differnt content file names that you want to load.

Header.php

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Page title</title>
</head>
<body>
BLALBLA CONTENT

content.php

echo $content;

footer.php

</body>
</html>

This together will create one page wtih a dynamic content and a static header and footer( where you can also add static scripting).

This is just a basic idea on how you can achieve this.

The static content(header and footer) might as well be cashed to load it faster.

Additional info why i think this

Also when you open the link into a tab, you will see that every of that link will contain the header. As with, for example, an iFrame only the dynamic content will be shown in the link.



Answered By - nkmol
Answer Checked By - Pedro (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing