Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Indexing Modular and Custom Field Content with Flex Pages #102

Open
thekenshow opened this issue Sep 30, 2020 · 7 comments
Open

Indexing Modular and Custom Field Content with Flex Pages #102

thekenshow opened this issue Sep 30, 2020 · 7 comments
Assignees

Comments

@thekenshow
Copy link
Contributor

I'm not able to get modular and custom field content indexed with Flex Pages enabled, despite creating a template as explained in the docs.

I have a modular page with a few modules that use a custom blueprint:

modular.en.md
    infolist.en.md
    infolist.en.md
    infolist.en.md

The following YAML appears in modular.en.md:

content:
    items: '@self.modular'

The module page content in infolist.en.md looks like this:

<p>We are the XYZ experts, from a very-unique-word and more.</p>

The modular page custom field content in infolist.en.md looks like this:

listitems:
    -
        itemtitle: Something
        itemimage: someimage.jpg
        itemimageloc: center
        itemicon: null
        itemiconloc: null
        itemdesc: '<p>A bit of text with another-very-unique-word in it.</p>'

I've created a templates/tntsearch/modular.html.twig file to capture modular and custom field content:

{% for module in page.collection() %}
<p>
    {{ module.content }}
    {% for info in module.listitems %}
      {{ info.itemtitle }}
      {{ info.itemdesc }}
    {% endfor %}
</p>
{% endfor %}

{{ page.content }}

When I index the site, I get only the parent modular.en.md page content, and nothing from the infolist.en.md module page content or custom field.

Could this be related to the lack of Flex Page support for @self in blueprints as noted at Page Blueprint with filepicker field does not recognize folder value of @self?

@mahagr
Copy link
Contributor

mahagr commented Oct 2, 2020

The @self issue in filepicker should be separate to this one (upload handling was missing support for it); modular pages should work just like they do with the regular pages.

I need to take a look what's going on here...

@mahagr mahagr self-assigned this Oct 2, 2020
@thekenshow
Copy link
Contributor Author

OK, let me know if you need more information.

@mahagr
Copy link
Contributor

mahagr commented Oct 9, 2020

You are missing:

tntsearch:
  template: 'tntsearch/modular.html.twig'
content:
    items: '@self.modular'

@thekenshow
Copy link
Contributor Author

Er, thanks ( :embarrassed: )

I've added that to all modular pages, rebuilt the TNT Index, and cleared the cache. There is still no sign of page.content, itemlist.itemtitle, or itemlist.itemdesc text from infolist.en.md in the search results. Worse, the parent modular.en.md page content (the "very-unique-word" example above) is no longer being found either. When I remove the tntsearch: from the header, the parent page content is restored in the search results.

@thekenshow
Copy link
Contributor Author

Another data point: if I drop the templates/tntsearch/modular.html.twig into a parent page, the content of the child modules is rendered:

{% for module in page.collection() %}
<p>
    {{ module.content }}
    {% for info in module.listitems %}
      {{ info.itemtitle }}
      {{ info.itemdesc }}
    {% endfor %}
</p>
{% endfor %}

{{ page.content }}

@mahagr
Copy link
Contributor

mahagr commented Oct 21, 2020

You mean if you put the modules into the main template of the page it works?

Does this new code work in the regular pages, btw?

@thekenshow
Copy link
Contributor Author

thekenshow commented Oct 21, 2020

Hi - meant to update this issue. I reach out to Trilby for paid support and @rhukster was able to get my site working for launch. The changes he came up with were:

  1. Turned off front-end Flex pages.
  2. Replaced
tntsearch:
  template: 'tntsearch/modular.html.twig'

with

tntsearch:
  template: 'tntsearch/modular'
  1. Changed user/data/gantry5/themes/rt_photon/templates/tntsearch/modular.html.twig to:
{% for module in page.collection() %}
  {{ module.content|raw|striptags }}
  {% for info in module.header.listitems %}
    {{ info.itemtitle|raw|striptags }}
    {{ info.itemdesc|raw|striptags }}
  {% endfor %}
{% endfor %}
{{ page.content|raw|striptags }}

The |raw|striptags was to remove unwanted characters that were getting in somehow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants