I use a PHP Switch statement to determine the pages of my website. So here is an example:
switch($page) {
case "about":
$title_name = "About Us";
$page_content = "includes/about-us.php";
include("inner.php");
break;
case "services":
$title_name = "Services";
$page_content = "includes/services.php";
include("inner.php");
break;
}
And my file structure is index.php?page=about which converts to /about/ using htaccess.
What I want to do is take all of my pages in that switch statement and automatically grab it and put it in a list so I can automatically have it write to my footer page where I will have all of the links.
So instead of manually typing in all of the links in the footer like: Home | About Us | Services | FAQ , it will pull it automatically based on the pages I provided in the Switch statement.
Is there a way to do this? It would also be good to automatically be able to add new pages and it will add a new case for the new page, and automatically create the page in the includes folder.
If anyone can point me in the right direction I would really appreciate it. From my understanding, I don’t believe you can do this with a switch statement, I would have to re-work the way I call the pages, right?
Nope, it’s not possible using
switch– but you could store those informations in an array: