I'm having difficulty searching for what I'm asking and haven't found anything satisfactory. I want to build a simple 2-3 menu system. In the lowest level menu, each menu should have several pieces of data of files. This may be an SQL record, an HTML file, or a PDF file. A record may need to exist under several different menus. Is there a usual way to do this so that each record is accessed from several different menus, but the record only exists once so that when it is updated, the update is sync'd in every menu?
In my case, I'm serving PDF's with instruction documents, but some instructions may need to be visible under multiple headings so they are easier to find. I could just duplicate the menus with a directory tree, but that would implicate multiple files, which I want to avoid to ensure no errors in updating the files. Using a directory structure also means I couldn't switch to hosting from a database in the future.
Here's pseudocode to demonstrate my current concept. Store records as files in a single directory, or else as database entries, whatever. Make a menu system that can store links to a record, this way as many links to a single record can exist in any number of menus. This should serve fast even for a large number of menus/records. To update, a new record is made, and the entire menu system is iterated to update every instance of the old link. This is slow, but unimportant since updates will be very rare events in my use case.
struct MenuElement {
array subMenus[];
array records[];
}
void UpdateMenuRecordLinks(oldRecordLink, newRecordLink) {
for ( i in MenuElements ) {
for ( j in i.records ) {
if ( j == oldRecordLink ) then j = newRecordLink;
}
}
}
void ServeMenu(menuLink) {
Display(menuLink);
while (true) {
input = GetUserSelection();
Display(input);
}
}