Hi there,

I've got a search view set up, using Search API. I've tried entering: [facetapi_active:facet-label]: [facetapi_active:active-value] into the page title pattern setting, but it's outputting it as "[facetapi_active:facet-label]: [facetapi_active:active-value]" and not the name of the facet.

Is the module compatible with Search API/ Views?

Thanks!

Comments

SergeyR’s picture

may be you miss "list" (see descrption)

ygerasimov’s picture

Status: Active » Fixed

@jaxxham you need to use "list<[facetapi_active:facet-label]: [facetapi_active:active-value]>" instead.

Status: Fixed » Closed (fixed)

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

Sinan Erdem’s picture

Status: Closed (fixed) » Active

I am also not able to make it work.

I tried to set like:
list<[facetapi_active:facet-label]: [facetapi_active:active-value]>
and it displays the same string.

I also tried this token:
[facetapi_active:facet-label]
which doesnt work also.

Other page title tokens are fine.

dydave’s picture

Hi Sinan Erdem,

I think it might be a good idea for you to take a look at #1863780-4: Integration with Meta tags API: Facetapi tokens support, I guess this would probably answer your previous questions.
If you wanted to get facetapi_active and facetapi_facet working with Page Title, you could perhaps copy over and adjust some of the code from this patch, in particular:

<?php

    // Provide explicit information for $data for the key facetapi_active_item
    // if any facetapi_active_item not wrapped in list<...> is found
    if (preg_match_all('/[^list<]\[facetapi_active:[^>]/', $pattern, $matches)>0) {
      // Select the item that was added last (so the most recently added filter).
      if ($item = end($adapter->getAllActiveItems())) {
        $item['adapter'] = $adapter;
        $types['facetapi_active_item'] = $item;
      }
    }

    // Provide explicit information for $data for the key facetapi_facet
    if (strpos($pattern, 'facetapi_facet') !== FALSE) {
      // Select the item that was added last (so the most recently added filter).
      if ($item = end($adapter->getAllActiveItems())) {
        $facet_name = $item['facets'][0];
        $types['facetapi_facet'] = facetapi_facet_load($facet_name, $searcher);
      }
    }

?>

Based on that and to help you test this issue further, I have put together a quick patch against the latest dev version, for the integration with Page Title, attached to this comment:
facetapi_bonus-get-page-title-working-1677310-5.patch
that should work better for the replacement of the patterns mentioned in #4.


*However*, I would like to attract your attention and perhaps get your support on the fact that none of this code would be required if the patch at #1856436-1: Facetapi Tokens: Attempt to initialize tokens based on current active searchers. could be applied to facetapi.tokens.inc.
In other words, this issue could also be fixed by applying this patch:
facetapi-initialize-default-tokens-active-searchers-1856436-1.patch
which fixes the problem at the source, reduces hooks implementations, code duplication (in third party modules) and is only called when the tokens really need to be replaced without any $data values.
I would greatly appreciate if I could get some of your support on this as well with testing, feedback, comments about this idea and choice of implementation to try to fix these problems.


Feel free to let me know if you would have any questions on any points/code/aspects of these tickets or patches, I would surely be glad to provide more information.


I would greatly appreciate if you could take a bit of time to look into the patch and give me your feedback/opinion on these changes.
Any feedback, testing, changes, recommendations would be highly appreciated.
Thanks in advance.

 

giorgosk’s picture

Issue summary: View changes

I don't understand on the front page of the project it says
" Integration with Page Title module" is this complete or it needs a patch to work
because I go to the page_title settings and sure enough I find the "facet" tokens but don't work
I also tried #2 suggestion and combinations of that but to no avail
page_title does not like any of those tokens

a small tutorial would probably help if this functionality is working