Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
  • Register
Welcome to the Q&A for Question2Answer.

If you have questions about the platform, click here to ask and please use English.

If you just want to try Q2A, please use the demo, which also grants admin access.

Apr 29: Q2A 1.5.2

How to use variable again ? php Question.

+1 vote
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
asked Jan 25 in Q2A Core by monk333

1 Answer

+1 vote
 
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.

answered Jan 26 by gidgreen
selected Jan 26 by monk333
Perfect, thank You, never learned php so from time to time the easiest things are impossible to resolve...