how to load local files inot a div from a menu of many html doc links

23 Views Asked by At

I have a note taking system I have used with students using frames. Going to flexbox using jquery. This system has more than 1000 files for notes for each class (as in school). Is there a way to write a jquery command that loads based based on "html" rather than write out each link individually. My menu is a pure css ul li setup. The note system is run offline. Flexbox with jquery has my head spinning for more than 6 months. Before I try to learn how to load a huge menu and files (more than 2 gb) online for folks to see, is this possible? Please be kind, I am a teacher who is trying to make solutions to help students, not a programmer.

1

There are 1 best solutions below

0
cssyphus On

We need to know more about your configuration/setup in order to best answer your question.

First, we would need to know how to get a list of files from where they are stored. Are you using a LAMP stack? (WAMP or MAMP or XAMP?) Where are the files stored, and how does WordPress access them (assuming megamenu refers to the the WordPress add-on?)?

Usually, you can get a list of files in a folder using a server-side language like PHP or NodeJS. For PHP, you need to be using a LAMP stack (that's what the P stands for). WordPress sites generally use PHP - and if you are running it offline then you probably are using a LAMP stack - but we need to know that.

Also, jQuery has a $.load() command that allows you to load the contents of a file into a div (or other HTML container). Logic-wise, you could loop through all files in the folder via PHP and output an HTML table containing an a tag for each file, that, when clicked either opens that file or (using $.load()) reads the file and puts the contents into another div on the page.

Assuming a PHP back end, here are some resources that will show you how to get a list of all the files in a folder, loop through them, and output some HTML:

List all files in one directory PHP

PHP script to loop through all of the files in a directory?

Loop through all images in folder, output HTML to display image

Full basic course for learning PHP (excellent and fast-paced):