Highlighted

Include page

New Here ,
Apr 30, 2020

Copy link to clipboard

Copied

I need to make changes to my developed site (10 years ago) with the CS6 version to add a single menu for all pages. I created a 'menu' folder containing menu.php.
In the header of my pages, I add the instruction: '<? Php include' menu.php '; ?> '. According to the hierarchy, the pages of the site are not always displayed identically.
Some present the menu, others the menu without the icons included, or no menu. On each page, links to CSS are present.
Can you help me ?
Cordially

Views

296

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Include page

New Here ,
Apr 30, 2020

Copy link to clipboard

Copied

I need to make changes to my developed site (10 years ago) with the CS6 version to add a single menu for all pages. I created a 'menu' folder containing menu.php.
In the header of my pages, I add the instruction: '<? Php include' menu.php '; ?> '. According to the hierarchy, the pages of the site are not always displayed identically.
Some present the menu, others the menu without the icons included, or no menu. On each page, links to CSS are present.
Can you help me ?
Cordially

Views

297

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Apr 30, 2020 0
LEGEND ,
Apr 30, 2020

Copy link to clipboard

Copied

Always an issue with php includes unless ALL of your pages are in the root of the folder. Whats happening is the links to the assets are incorrect AFTER being included in your pages because some of the pages are in folders another level up from where the links to your assets say they are in the php includes.

 

I tend to use absolute urls in php include files. So in the php include file I set a $url variable for working locally and one for the remote. I uncomment the correct variable for working in the local or remote environments:

 

<?php

// localhost - $url = "http://localhost/nameOfSiteFolder/"

// remote host - $url = "http://domainName.com/""

?>

 

Then I assign absolute url paths to the links and the image assets in the php include file:

 

<li><a href="<?php echo $url; ?>pages/about.php">About Us</a></li>

<img src="<?php echo $url; ?>images/logo.svg" alt="">

 

You can then store your pages and images in any folder you like in your site folder as the paths to them will always be absolutely assigned instead of relatively assigned.

 

Only downside is your management skills need to be good as you can sometimes forget to comment out the local $url and uncomment the remote $url when re-uploading the php includes if you make changes to the content in the php include files.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 30, 2020 0
Adobe Community Professional ,
Apr 30, 2020

Copy link to clipboard

Copied

Links inside include files must be relative to the parent document, not the include file.  And if you don't keep all your site pages at the server's root level (same as your index), things tend to break.

 

Use site root-relative or absolute links in your include files.

https://helpx.adobe.com/dreamweaver/using/linking-navigation.html

 

Nancy O'Shea, ACP
Alt-Web.com

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 30, 2020 0
New Here ,
May 02, 2020

Copy link to clipboard

Copied

I converted all html pages to php.
Beginner in php, I did not know how to apply your instructions, to place and in which file to apply the changes : menu.php or index.php.
I used the code : <?php include('menu/menu.php'); ?> for the inclusion of my menu in the header of all pages.
Depending on the tree structure, the menu may or not appear.
The attached image indicates to what level the code works.
I also tested the following code include $_SERVER['DOCUMENT_ROOT']."/menu/menu.php"; which did not have a correct result.
What can you advise me ?
Cordialement
Mercihierarchie.jpg

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 02, 2020 0
Adobe Community Professional ,
May 02, 2020

Copy link to clipboard

Copied

Your site structure is overly complicated which is a problem. Either simplify your site structure by moving pages to Site Root level or use absolute URLs for navigation links.  Your choice.

 

SITE ROOT

animaux.php

art.php

galerie.php

index.php

etc....

 

ABSOLUTE URL in menu.php

<a href="https://yourdomain.com/galerie/animaux/ani.php">Link to Animation</a>

 

 

Nancy O'Shea, ACP
Alt-Web.com

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 02, 2020 0
New Here ,
May 03, 2020

Copy link to clipboard

Copied

There are up to 4 levels in my website :

Root - index.php

Folders: index.php

Folders 1 – 2 : index.php

Folders 1 - 2 – 3 : index.php

Menu folder : menu.php

Css folder : * .css

Image folder : * .jpg

js folder : * .js

These last 4 Folders have links to the different levels above

 

Example:

In the Folder :

- Gallery / animals / index.php

- Gallery / flowers / index.php

...

In the Folder :

- Media / press / year / news_paris_25-10

- Media / press / year / news_lon14-08

 

It seems complicated to group all the files in the root.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 03, 2020 0
Adobe Community Professional ,
May 03, 2020

Copy link to clipboard

Copied

Organize things however you like.  As long as it makes sense to you and you can work with it that's all that matters.

 

I prefer to build sites dynamically from content stored in an online database. This results in fewer actual pages and a very basic site structure.  On the server, this structure can support 1,000+ dynamically generated pages.

 

SITE ROOT

about.php

contact.php

detail_page.php

index.php

summary_page.php

   +Admin

   +Images

   +Includes

   +Scripts

   +Styles

 

Nancy O'Shea, ACP
Alt-Web.com

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 03, 2020 1