Using this custom function when webpages are in sub-folders.
Greetings Alena from the UK,
Firstly thank you for your tutorials I'm learning at an incredible rate. I have a question about using this function when the webpages are in subfolders.
When we go through the tutorial the pages we create are all in the main directory. However as you may appreciate larger websites may have many sub-folders.
My question is how can I utilise this piece of code for a template across a whole website which contain many sub-folders?
I have tried implementing this but the code does not seem to load the "li" 's.
Thank you in advance.
Codin - Codesmite8,590 Points
What I normally do is have all my include files in a folder called "includes"
So say for example we have our website root:
"articles.php" isn't at the root like "index.php" it is in a folder called "somefolder"
Lets say I have a file called "myinclude.php" and I need I to use it on every page including the one in the "somefolder" subfolder.
I will place "myinclude.php" into another subfolder called "includes" so now our website root looks like this:
root/index.php root/somefolder/articles.php root/includes/myinclude.php
On both index.php and articles.php I will write my include like this:
Relative paths that begin with "/" will start from the root regardless of where the file is located.
Whereas for example like in the video if you had:
This will work from index.php as index.php is located at the root, so it will read as "root/includes/myinclude.php".
But if you were to do the same from the articles.php file it will read as "root/somefolder/includes/myinclude.php" as it will start from the same level as the myinclude.php file.
Hope this helps :)