policyoftruth
policyoftruth

Reputation: 11

PHP require files

I am currently working on a website and the nav looks like this

enter image description here

I have primarilly made a page template that is shared by all the pages.The picture follows shows how i tried to break down the template into different pieces.

enter image description here

now I have to keep all files in the main directory. I can't put related pages for example all listing pages in listing folder or all download pages in download folder etc because it can't access the require files. I have tried using .. operator but the template is so nested that it is not helping either.

My question is what strategy do I use so that I can use template pieces yet all related files can be grouped in folders rather than keeping all files in the main directory. That looks really messy

Thank you.

Upvotes: 0

Views: 53

Answers (1)

Blue Rose
Blue Rose

Reputation: 533

You should not put all files in your main directory which will look messy and confusing.

Better you put required files in their respective folders and call them properly.

In index.php-> its okay how you have included files.

But in init.php -> you don't need to write folder name "core" as init.php is already inside core folder. So simply use

require('connect.php');

Similarly in header.php

 require('logo.php');

And in footer.php

require('counter.php');

If you have any problem, plz let me know.

Upvotes: 1

Related Questions