Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+1 vote
603 views
in Q2A Core by
Inside the advanced theme, function head_title(),  I have build a variable : $myheadertitle using a db query and some php. (I am very proud up to that point ; )

But now I need this variable two times more inside other functions. I am sure it is worst practice to make two more db requests, so , how would i make that variable available for all theme functions ?

May be a very simple question, but for the php novices like me this is still a VERY big problem...

Thanks for any hints...
Q2A version: 1.5

1 Answer

+1 vote
by
selected by
 
Best answer

In your advanced theme class declaration, add a line like this outside of any function definitions:

var $myheadertitle;

Then you can access $this->myheadertitle within your advanced theme code to store and/or retrieve the value.

by
Perfect, thank You, never learned php so from time to time the easiest things are impossible to resolve...
...