MyBB Community Forums

Full Version: How to display search keyword on search results page?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi there -- does anyone know which variable can be inserted into the search_results_posts template (directly or inside of a PHP conditional) to display the keyword that was searched? I'm trying to modify the results page from "Search Results" to "Search Results for X".

Thanks!
You can use $search['keywords'], so maybe:

<strong>{$lang->search_results} for "{$search['keywords']}"</strong>

Would look like this:

[attachment=45718]
Thanks! That worked.
(2023-01-14, 04:53 PM)Matt Wrote: [ -> ]You can use $search['keywords'], so maybe:

It work good, except it show for all search, for example with "View New Posts".

Need : PHP in Templates and Template Conditionals

to do
<if $search['keywords'] then> for "{$search['keywords']}"</if>
(2023-01-16, 06:44 AM)Firnus Wrote: [ -> ]
(2023-01-14, 04:53 PM)Matt Wrote: [ -> ]You can use $search['keywords'], so maybe:

It work good, except it show for all search, for example with "View New Posts".

Need : PHP in Templates and Template Conditionals

to do
<if $search['keywords'] then> for "{$search['keywords']}"</if>

Excellent idea -- just noticed this (same with post history, thread history for users). Cheers to both of you!