I am modifying a wordpress site that is for online lessons.
I am modifying the lesson template which originally had one navigation sidebar for a lesson.
I have added a vertical tab switcher so that I can display other things related to lessons (so I will have dynamic vertical tabs where user can choose
discussions in navigation bar) and in stepping through the code in PHPStorm with xdebug I noticed that there are a lot of calls to
get_posts() made in various template part builders.
So you have this sort of structure:
Load lessons navigation menu Display basic lesson info Call a function to get topics and display topics Call another function to get topic quizzes ... Now display main content
The thing is, a lot of the info I want to display in other navigation tabs (, say
discussions) is info already extracted in previous function calls for building the
syllabus navigation tree but which are not available to me after the function's return back to the main template.
Now, I can redo various function calls, but seems like such a waste.
How does one typically pass post data among the various scripts that are used to render a page so that you don't have to redo queries?
Above said, would something like
angularjs be a better approach to dealing with post data and having it available to all the HTML elements that I deem necessary?
Just trying to figure out how you typically address this sort of data sharing across scripts without just declaring a bunch of globals (or is that valid way?)