Thread:Project:Support desk/How to reuse search query in footer

I want to use something like Extension:Header Footer to add a box at the bottom of Special:Search. How could I implement this so that the search query can be used as a variable in the box's template code?