Skip to content

Instantly share code, notes, and snippets.

@gjhead
Created October 1, 2021 14:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gjhead/fc65472c003bbb27c3adbf8fd6c37457 to your computer and use it in GitHub Desktop.
Save gjhead/fc65472c003bbb27c3adbf8fd6c37457 to your computer and use it in GitHub Desktop.
You can query for that parent page's entry model with a new ElementCriteriaModel.
{% set mainEntry = craft.entries.id(100).first() %}
{% if mainEntry %}
{% set matrixField = mainEntry.matrixFieldHandle %}
{% set firstContentBlock = matrixField.type('content').first() %}
{% if firstContentBlock %}
{{ firstContentBlock.myRichTextFieldHandle }}
{% endif %}
{% endif %}
Instead of using the entry's ID as the link to that entry, you can also use other parameters to query for the entry model. Here's an example using slug and section:
{% set mainEntry = craft.entries.section('news').slug('main-news').first() %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment