Skip to content
View in the app

A better way to browse. Learn more.

JimiWikman.se

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Access attributes in Pages custom fields like label (name), etc

Hi there, I posted this at the IPS communities, but I thought it might get a little more direct attention over here.

In a Pages DB display template, I can get custom field data with
 

                    {$record->customFieldDisplayByKey('programs')|raw}

And In the Display are of the field, I can set the {$label} and the {$value} as well as use the {$formValue}

But what I really need to do is access the custom field's Name (label) and Description from within the Record Display template.

Is that possible?Something like:

{{foreach $record->customFieldsForDisplay('display_top') as $fieldId => $fieldValue}}
	custom field key: {$fieldId}

  // this doesn't exist, does it?
  {$record->customFieldDisplayByKey($fieldId,'LABEL')|raw}
  {$record->customFieldDisplayByKey($fieldId,'DESCRIPTION')|raw}
  // this doesn't exist

{{endforeach}}

Thanks.

  • Replies 4
  • Views 1.7k
  • Created
  • Last Reply

Top Posters In This Topic

Most Popular Posts

  • ooh! This is a great idea. Thanks for offering it. A nice workaround. I'll set up {$label} for the 'listing' type and see what I can do. I wanted to do this in a somewhat automated way, though I

  • In case someone stumbles on this in the future, here is a way to get the Custom Field name in any database: Remember to replace the <database_id> with the id for your Pages database, so for da

Featured Replies

  • Owner

You can get the label, that should not be a problem.

{$record->customFieldDisplayByKey($fieldId,'THIS VALUE')|raw}

The value after fieldID determine what template it will use. Listing is what you put in the listing settings, Display what you put in the display setting and raw output as if you set no settings, kindof 🙂

In the settings for display you can set custom and then in that area you can place just the label. Then you can use Display to post the label.

Description however I have never tried, but since it is part of the field object it should be possible to output somehow. It is intended for the form and in the admin area, so it might be a bit tricky to get for the presentation templates like display and listing.

  • Author

ooh! This is a great idea. Thanks for offering it. A nice workaround.

I'll set up {$label} for the 'listing' type and see what I can do. I wanted to do this in a somewhat automated way, though I could have inserted each field with a custom label in the template code:

Label: Programs
Data: {$record->customFieldDisplayByKey('programs','processed')|raw}

Label: Notes
Data: {$record->customFieldDisplayByKey('notes','processed')|raw}

But I like your idea much better as we have 30-40 fields.

Thank you!

  • Author

In case someone stumbles on this in the future, here is a way to get the Custom Field name in any database:
Remember to replace the <database_id> with the id for your Pages database, so for database ID 21, the code will look like this: \IPS\cms\Fields21::load ...

{{foreach $record->customFieldsForDisplay('display_top') as $fieldId => $fieldValue}}
  {{$field = \IPS\cms\Fields<database_id>::load( $fieldId, ‘field_key' );}}
  Custom field key: {$fieldId}
  Label: {$field->_title}
  Description: {$field->_description}
  Custom Field Value: {$record->customFieldDisplayByKey($fieldId,'processed')|raw}
{{endforeach}}

 

 

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.