Jump to content

Recommended Posts

Hello

 

sorry if this is incredibly beginner, it is my first post, and couldn't find anything / didn't know what to search for :shrug:

 

I have set up a navigation menu in "core/linkmenu.php"

 

which shows my navigation links e.g.

 

<a href="index.php">Home</a>

 

and included it in the first directory page index.php with "<?php include("core/linkmenu.php"); ?>"

 

so there is a link on the index page (index.php) and all pages in the same directory level to the navigation links found in core/linkmenu.php

 

 

However in my subdirectories, if I try to use <?php include("../core/linkmenu.php"); ?>

it will take me to /subdirectory/index.php. and thus return an error page. as the actual page is a directory higher.

 

so what should I do to remedy this?

as I would like only 1 page that holds the navigation links and not create different linkmenu pages for each subdirectory level.

 

Thanks very much for reading and hope you can help me out

Link to comment
https://forums.phpfreaks.com/topic/273872-subdirectory-linking-issue/
Share on other sites

ah yes that would work. thanks very much. However is that accepted practice? as if you were editing/testing offline using localhost root folder then you would have to change every link to the online server every time you wanted to upload editions

I always set up my paths in my constants. This way if you are changing directories, you only have to change it in one file to affect the whole site.

Example:


define('PATH',$_SERVER['DOCUMENT_ROOT']);
define('SITE','http://' . $_SERVER['SERVER_NAME']);

  • 2 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

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.