Entry Wrapper

Entry wrappers provide the properties and methods for interfacing with entries via your twig templates. You will be working with an \Enact\template\wrapper\Entry instance whenever you are interacting with an entry field or the global twig variable entry.

Entry Properties#

  • id - The unique ID of the entry.

  • userId - The unique ID of the user who created the entry.

  • lastEditedByUserId - The unique ID of the user who last edited the entry.

  • title - The title of the entry.

  • url - The url of the entry.

  • slug - The slug of the entry.

  • createdOn - The date the entry was created on.

  • lastEditedOn - The date the entry was last edited on.

  • status - The status of the entry (disabled, pending, published, expired).

  • publishOn - The date the entry is/will be published on.

  • expireOn - The date the entry is/will be expired on.

  • entryOrder - The order of the entry (only applicable for structure and category section entries).

  • atDepth - The depth the entry lives at (only applicable for structure and category section entries).

  • parentId - The unique ID of the parent entry (only applicable for structure and category section entries).

  • parentTitle - The title of the parent entry (only applicable for structure and category section entries).

  • parentSlug - The slug of the parent entry (only applicable for structure and category section entries)

  • parentUrl - The url of the parent entry (only applicable for structure and category section entries).

  • sectionId - The unique ID of the section the entry is contained within.

  • sectionHandle - The handle of the section the entry is contained within.

  • sectionName - The name of the section the entry is contained within.

  • sectionLayoutId - The unique ID of the section layout the entry is contained in.

  • sectionLayoutHandle - The handle of the section layout the entry is contained in.

  • sectionLayoutName - The name of the section layout the entry is contained in.

  • layout - Alias of sectionLayoutHandle.

Accessing properties

{% set e = entry.yourFieldHandle.entryFieldHandle[0] %}

<p>Entry title : {{ e.title }}</p>

<p>Uses layout : {{ e.sectionLayoutName }}</p>

<p>Found at : {{ e.url }}</p>

Entry Fields#

Each field contained in the section layout used by the entry gets its own primary real estate as a property of the entry accessed by the fields handles respectivly.

So if the entry had an asset field with the handle backgroundPic and a rich text field with the handle content it would be accessed like so:

{{ entry.backgroundPic.assetFieldHandle[0].getImgHtml }}

<div class='content'>

    {{ entry.content }}

</div>

Entry Methods#

Some of the methods will return a \Enact\template\lookup\Entry which allows for the lookup of entries via twig templates.

  • getLinkHtml - Get a <a> html element set wit the appropriate href and title attributes set accordingly, and the link text as the title of the entry. Pass an array as an argument to override or set your own attributes on the <a> element.

  • getCreatedByUser - Get the user who created the entry as a \Enact\template\wrapper\User.

  • getLastEditedByUser - Get the user who last edited the entry as a \Enact\template\wrapper\User.

  • getChildEntries - Returns a \Enact\template\lookup\Entry with the parentId set to the current entry id. Call the fetch method immediately after this method to get the child entries as an array of \Enact\template\wrapper\Entry, or add more conditions to refine the lookup and then call the fetch method.

  • getParentEntry - Returns the entries parent as a \Enact\template\wrapper\Entry.

  • getSibilingEntries - Returns a \Enact\template\lookup\Entry with the appropriate fields set to get the sibling entries. Call the fetch method immediately after this method to get the sibling entries as an array of \Enact\template\wrapper\Entry, or add more conditions to refine the lookup and then call the fetch method.

  • getPrevEntry - Get the previous sibling entry to the current entry as a \Enact\template\wrapper\Entry.

  • getNextEntry - Get the next sibling entry to the current entry as a \Enact\template\wrapper\Entry.

  • getOwnedByTag - If the entry is owned by a tag, this will return a \Enact\template\wrapper\Tag representing the owning tag.

  • getTaggedEntries - If the entry represents a tag, use this method to get other entries which are tagged by the current entry tag. Call the fetch method immediately after this method to get the tagged entires as an array of \Enact\template\wrapper\Entry, or add more conditions to refine the lookup and then call the fetch method.

  • getOwnedByAsset - If the entry is owned by a asset, this will return a \Enact\template\wrapper\Asset representing the owning asset.

  • getOwnedByUser - If the entry is owned by a user, this will return a \Enact\template\wrapper\User representing the owning user.

Using the methods

If you call the field without any properties or methods it is the equivalent of calling the getLinkHtml method.

<ul>

{% for e in entry.yourFieldHandle.entryFieldHandle %}

    <li>

        {{ e }}

        <div class='children'>

            {% for child in e.getChildEntries %}

                 <a href='{{ child.url }}'>{{ child.title }}</a>

            {% endfor %}

        </div>

    </li>

{% endfor %}

</ul>