getgrav / grav-premium-issues

Official Grav Premium Issues repository to report problems or ask questions regarding the Premium products offered.
https://getgrav.org/premium
7 stars 2 forks source link

[algolia-pro] Preview/Snippets Not Appearing #282

Open thekenshow opened 2 years ago

thekenshow commented 2 years ago

I'm not getting snippets for my algolia-crawl-pages index, just a list of page titles.

Screen Shot 2022-05-02 at 4 21 42 PM

When I test it on Algolia (second image), i see a content section with highlighted matches:

Screen_Shot_2022-04-29_at_1 00 04_PM

Snippets do appear in CLI:

Screen Shot 2022-05-03 at 7 24 32 AM

The inspector shows nothing hidden in HTML:

Screen_Shot_2022-04-29_at_3 26 12_PM

And the Console shows no related errors:

Screen Shot 2022-05-02 at 4 20 55 PM

I can provide a zipped user folder if that helps to reproduce this.

rhukster commented 2 years ago

Ok sorry for taking so long with this, but I looked into it yesterday and i kept running into minor issues (specifically with crawl) that kept me busy all day fixing.

I've now released a version 1.0.6 which should be available within the hour. This contains various minor fixes. Some of which may or may not help your issue. However, while trying to recreate the issue I did discover the combination of things that were missing in the default crawl configuration that might of caused yours.

Specifically the front end config needed to be in the right place and have preview enabled:

aloglia-pro.yaml:

crawl:
...
  interface:
  ...
     preview:
       enabled: true
       toc: true
...

Even after that I got the title showing, but no content summary.. That was because crawl also had another bit missing:

aloglia-pro.yaml:

crawl:
...
  interface:
  ...
     search_params:
       hitsPerPage: 20
       distinct: true
       snippetEllipsisText: '…'
       attributesToSnippet: ['summary:50', 'content:50']
...

Specifically the attributesToSnippet needed to contain summary:50

I suggest updating to 1.0.6 as there are some important 'crawl' things fixed that will definitely impact you, but I think your underlying issue is this configuration.

thekenshow commented 2 years ago

Thanks - I'll install 1.06 as soon as it's available, confirm the yaml changes above, and let you know what happens.

thekenshow commented 2 years ago

As of this morning, I'm still not seeing an update for this plugin:

Found 27 packages installed of which 2 need updating
Packages not found or not requiring updates: algolia-pro
thekenshow commented 2 years ago

Updated, applied changes noted above. re-indexed, cleared cache, still the same behaviour I originally described.

Your suggestions above had a different location for the search_params: section. You had:

crawl:
...
  interface:
  ...
     search_params:
       hitsPerPage: 20
       distinct: true
       snippetEllipsisText: '…'
       attributesToSnippet: ['summary:50', 'content:50']
...

But my config was:

crawl: ... search_params: hitsPerPage: 20 distinct: true snippetEllipsisText: … attributesToSnippet:

I tried all combinations of the syntax and locations:

Nothing made any difference.

Note that this site is PHP 7.3.33, in case that's a possible problem.

I can send a zipped user folder via discord DM.

rhukster commented 2 years ago

Yes, please zip and send me the zipped user folder. I suspect you have some bad config.

thekenshow commented 2 years ago

Zip provided, please test and advise.

rhukster commented 2 years ago

Ok, i was able to get this installed locally and I looked over you files. Those all looked fine to me. Ironically messing about with a gantry theme is too complicated for me, so i just switched to quark and put a trigger in the base.html.twig:

<button type="button" data-algolia-pro-trigger>Search</button>
{% include 'partials/algolia-pro/instantsearch.html.twig' ignore missing with { index: 'crawl' } %}

Then i tested with "Suppression" and it output the preview as expected:

CleanShot 2022-05-25 at 14 52 43@2x

Note, you do of course have to hover over an item to get a preview as nothing is selected by default.

Also i'm not using your domain specific config, only the default ones from user/config/ so maybe you might have some issue with the configs in troy* folders.

thekenshow commented 2 years ago

I removed the domain-specific config and retested, same result. So user/config/plugins/algolia-pro.yaml is not the problem.

Screen Shot 2022-05-26 at 8 04 56 AM

I queried from the command line, and I get correct snippet results, so it's not Algolia.

Screen Shot 2022-05-26 at 8 06 13 AM

Hovering makes no difference, and inspecting the page HTML shows there's nothing there to reveal by hovering ("Foam appears in the Marine Fire Safety snippet):

Screen Shot 2022-05-26 at 8 31 39 AM

So what I'm hearing is the Algolia Pro plugin is not compatible with Gantry, but you're not able to go any further to find out why. Is that where this ends? Can @mahagr help?

rhukster commented 2 years ago

can you first please confirm if this works for you in quark?

thekenshow commented 2 years ago

Done, it works properly - exactly as you described above.

thekenshow commented 2 years ago

Fwiw, I tried copying the templates/algolia-pro and templates\partials to the Gantry theme customization folder (user\data\gantry5\themes\rt_photon\templates) and cleared caches, no change.

rhukster commented 2 years ago
CleanShot 2022-06-09 at 13 35 00@2x

You can see here that there is a hidden class that is causing this not to show. This should be removed by the JS (as you can see i removed the class manually and it shows) when there is a result hovered. I'm just not sure why this is working fine in Quark theme, but not in your theme, but clearly it's not a CSS conflict.

I think @w00fz is the only one that is boing to be able to determine what's going on here.

thekenshow commented 2 years ago

Right, I see that. Strange there wouldn't be a console message if it was a JS collision or fail. Looking forward to getting this sorted!

thekenshow commented 2 years ago

I'm going to lock this site down again but can reopen as needed.

thekenshow commented 2 years ago

Any update on this?

thekenshow commented 2 years ago

I determined that the hidden class is assigned by default in hits_preview.html.twig in the plugin. By editing that template to remove hidden, the preview panel appears and works. Obviously, this breaks the configuration settings that would control the display of previews.

To avoid getting overwritten by plugin updates, I created user/data/gantry5/themes/rt_photon/templates/algolia-pro/blocks/hits_preview.html.twig(custom RocketTheme, in my case) with the hidden class removed.

So not fixed, but working, in case anyone else runs into this issue.