Forum

Thread tagged as: Question, Api, Meta

itemUpdated data

Hi,

I am looking to access the itemUpdated data that is displayed when using the <perch:showall> tag within a template. The particular region is shared.

Is it possible to retrieve using the API or a perch function?

Thanks Marc

Marc Sanders

Marc Sanders 0 points

  • 2 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

If you can see it in <perch:showall> you should be able to use it by ID directly in the template.

Thanks Drew, I will see what I can do

It works but shows up in the editing form as an editable text field, is there a way to hide it from an editor?

Hussein Al Hammad

Hussein Al Hammad 105 points
Registered Developer

Hello Marc,

You can use type="hidden".

Hi Hussein,

I have already tried that as I thought that be the solution but no luck.

Hussein Al Hammad

Hussein Al Hammad 105 points
Registered Developer

Can you show us your template? A field with type hidden shouldn't show on an edit form.

<perch:content id="display" type="select" label="Display notification?" options="Yes|true, No|false" divider-before="Options" suppress="true" order="100" />
<perch:content id="itemUpdated" type="hidden" />

<perch:if id="display" value="true">
    <div class="mfp-modal mfp-hide" id="notification-modal" role="dialog" aria-labelledby="mfp-modal-heading">
        <perch:if exists="image">
            <div class="mfp-modal-img img">
                <img src="<perch:content id="image" type="image" label="Image" width="960" bucket="content" help="960px" order="11" />" alt="<perch:content id="alt" type="text" label="Alt text" help="A small bit of text to describe your image" order="12" />" />
            </div>
        </perch:if>
        <div class="mfp-modal-inner">
            <div class="body text-center">
                <h2 id="mfp-modal-heading" class="typography-heading"><perch:content id="heading" type="smarttext" label="Heading" html="false" required="true" escape="true" order="1" /></h2>
                <!-- TODO: Introduce basic editor option -->
                <perch:template path="content/body-basic.html" />
                <perch:if exists="button">
                    <a href="<perch:content id="url" type="text" label="URL" help="https://www.example.com or /section/page" order="14" />" class="mfp-modal-button button button--primary" role="button"><perch:content id="button" type="text" label="Button" divider-before="Button" order="13" /></a>
                </perch:if>
            </div>
        </div>
    </div>
</perch:if>

Marc Sanders

This template seems to function as it should. It does not show the field in the edit form for me and outputs the timestamp to the page when the edit form is saved.

It seems to work when using perch_content but not with perch_content_custom

Hussein Al Hammad

Hussein Al Hammad 105 points
Registered Developer

perch_content_custom() outputs content from an existing region. It doesn't affect your region's edit form.

Is there another method to access this field? Maybe through the api?

Hussein Al Hammad

Hussein Al Hammad 105 points
Registered Developer

You may be overthinking it a little.

The particular region is shared.

Create the shared region:

perch_content_create('My Region' , [
   'template' => 'my_template.html',
   'shared' => true,
]);

Output the region using my_template.html:

perch_content_custom('My Region');

Or if you wish to use a different template to output it:

perch_content_custom('My Region'. [
   'template' => 'my_other_template.html',
]);

You should be able to use the itemUpdated field in the template you use for output.