Help with auto-generated menu

Using the Auto-generated menu here that reads [h#] for the menu:

How can I do this from outside the file, with many files?

For example, I have a standard menu included in each file, that has a link to each file.  I would like to include a submenu based on the headings of each file as the above link does.

For example


Introduction link
  - link to H2 (1)
  - link to H2 (2)
  - link to H2 (3)
Page1 link
  - link to H2 (1)
  - link to H2 (2)
  - link to H2 (3)
Page2 link
  - link to H2 (1)
  - link to H2 (2)
  - link to H2 (3)

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You wouldn't want to do that on each hit, because your website would become very slow because of the number of files that need to be accessed on each and every request..

When you realy need this kind of setup it is usually better to only show the main menu items, and show the subheader only when you are in the corresponding file.
Another approach might be to use caching, but this would still involve a large amount of file/hard disk interaction.

A third way is to hardcode the menu, or drive it from a database.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.