1

The website I'm building contains several php files, each has its own functionality and can be accessed through a link (when u press a link, it directs you to the appropriate page).

I was thinking of implementing a side bar navigation, and bind each php file to a link ( button like).

How is this possible?

abedzantout
  • 802
  • 4
  • 15
  • 28

3 Answers3

0

You are thinking of a common UI menu, that links to the different (backend generated) pages of your site.

Its a fine design, but its not "Single page".

Single page application mean that a single backend page created the UI, and it is being altered by front-end manipulation, and perhaps some ajax calls to the backend. No real "links" to different backend pages are performed while inside the single-page-app.

Lavi Avigdor
  • 4,092
  • 3
  • 25
  • 28
  • oh okay, thank you for clarifying! so i just proceed without going down that route. I was just concerned that each time i press a link, the navigation bar will also be refreshed and wanted a way to just make things "smoother" – abedzantout Dec 20 '15 at 09:52
0

There are several ways on how to do this.

In your navigation bar you could pass along a variable in each button like:

index.php?action=readarticle

Then where ever you want to output the file you can do something like this:

<div id="leftmenu">your menu here (with links like index.php?action=readarticle)</div>
<div id="content">
<?php
if(isset($_GET["action"])) {
    switch($_GET['action']) {
        case "readarticle":
        {
            include('readarticle.php');
            break;
        }
    }
}
?>
</div>
Santy
  • 387
  • 2
  • 7
0

This wont work with just PHP..

You can work with javascript to make a single page application. There are many frameworks available.

Take a look at this question to see some that are available.

but you dont need a framework for this. This can also be done with pure javascript or with jquery.

I was just concerned that each time i press a link, the navigation bar will also be refreshed and wanted a way to just make things "smoother"

Here is a simple solution: Add eventlisteners(click) to your buttons or links. In the callback make a ajax request to grab the file (or jquery load()), and fill a element with the response.

Community
  • 1
  • 1
RFLdev
  • 186
  • 9