Hi,

I want to change meta description of search results page if there search query does not return any result, how I can do this?

Comments

DamienMcKenna’s picture

Status: Active » Fixed

You would have to write some custom tokens that could (somehow) sniff the search results, and then add them to a per-path definition.

Sharique’s picture

Status: Fixed » Active

Path is same so we cannot use per path definition.

We are using custom search search service. We created a panel page to for search which contains custom search form and results ctools content type. Results pane take parameters from query string, send request to services and render results, here I need to check results count and alter meta description.

Sharique’s picture

If I can alter metatag context I can do that. Is there a way to alter context before getting hook_metatag_metatags_view_alter called?

DamienMcKenna’s picture

Status: Active » Fixed

The by-path settings are just slightly customized Context definitions, and you could extend the by-path settings by using the main Context UI to add more conditions as needed - I believe there's a condition that will let you filter on the query string.

Sharique’s picture

Status: Fixed » Active

We cannot identify no of results returned by looking at query parameters. Hence we cannot by path settings.

DamienMcKenna’s picture

Version: 7.x-1.0-beta4 » 7.x-1.x-dev
Status: Active » Fixed

I'm not sure there's really a good way of doing this using Drupal's internal Search module, there isn't an obvious way to find out how many results there are without trying e.g. hook_preprocess_page to customize the meta tags based on the output of the page's content.

DamienMcKenna’s picture

Also, I'm sorry for not getting the point of your problem until now, but now that I understand what you're trying to do I do see it being tricky to work out.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.