Jump to content

Pages - Testing if database custom field is empty

Featured Replies

Posted

In 3.x IP.Content, this would work: <if test="!$record['custom_field_id']">

In 4.x I see some stuff like "{{if $record->customFieldsForDisplay" or "$record->customFieldDisplayByKey", but I can't figure out how to test if there's anything in the field.

Any ideas?

It’s so easy, you almost had it. You really just write this to test if there is content in the field …

{{if $record->customFieldsForDisplay('display')['your-key']}}

{{endif}}

or if you know the field ID it’s even simpler:

{{if $record->field_XXX}}

{{endif}}

 

  • Author

Cool, thanks. For some reason it didn't work using 'display', but I changed it to 'raw' and it worked. (My articles have a custom field to store a topic ID, and I show a link to the topic only if there's an ID stored in the field)

Sorry for my ignorance. I am trying to understand this language but can not find a doc. Any reference I can read to understand this ?

  • Author

Sorry for my ignorance. I am trying to understand this language but can not find a doc. Any reference I can read to understand this ?

I was looking for that earlier before starting this topic but I didn't find anything, well there's this http://community.invisionpower.com/4docs/, but it doesn't have anything about pages templates coding, hopefully they will add more information there.

Thanks @Ralf H.  I will go through and hopefully start to get it..

  • Author

Oh yep I saw that, but honestly... well I'm not a programmer and I do most of my stuff searching around, reverse-engineering existing code, trying, copying and pasting, getting errors, trying again, getting more errors, until something works...

What I mean is that I would never get to the code I needed with this "{if $foo}}" or "{$foo|raw}" as the examples. I meant to say that I hope they add more "real-life" examples rather than just the logic behind it.

Archived

This topic is now archived and is closed to further replies.

Recently Browsing 0

  • No registered users viewing this page.