Invision Community 4: SEO, prepare for v5 and dormant account notifications Matt November 11, 2024Nov 11
Posted July 8, 20204 yr Hi all. I'd loved to put some private fields in my Our Picks preview. I found the right place to do it : <div class='cPromotedWidgetItem_contentInner'> {{if $text = $item->getText('internal', true)}} <div class="ipsType_richText ipsType_medium ipsSpacer_both ipsSpacer_half">Note : {$item->customFieldDisplayByKey('my_key', 'display')|raw}</div> <div class="ipsType_richText ipsType_medium ipsSpacer_both ipsSpacer_half" data-ipsTruncate data-ipsTruncate-type='remove' data-ipsTruncate-size='4 lines'>{$text|raw}</div> {{endif}} {{$reactionClass = $item->objectReactionClass;}} {{if $reactionClass || $item->objectDataCount}} <ul class='ipsList_inline ipsType_light ipsSpacer_bottom'> {{if $reactionClass}} <li>{template="reactionOverview" group="global" app="core" params="$reactionClass, FALSE"}</li> {{endif}} {{if $counts = $item->objectDataCount}} <li><i class='fa fa-comment'></i> {$counts['words']}</li> {{endif}} </ul> {{endif}} </div> But I could not acces to my rivte field using {$item->customFieldDisplayByKey('my_key', 'display')|raw} Can anyone explain me my mistake ?? Thanks in advance
July 8, 20204 yr Author In fact I don't know how to go from $item to the full record that is currently shown....
July 8, 20204 yr $item->object()->customFieldDisplayByKey('my_key', 'display')|raw But be careful as this would result in an error if you promote anything other than a custom Pages database record.
July 8, 20204 yr Author Mhhh tried that but it did not worked 😞 But it is true that we already promote other thing than Custome entry. Is there any way of checking if the specific field is existing ?
July 8, 20204 yr Author 19 minutes ago, bfarber said: But be careful as this would result in an error if you promote anything other than a custom Pages database record. Ok I have exactly what you are saying : it is working for my records but noote for the otehr posts promoted from the forum. Any clue to avid that ? Can I check if my object is a record ?
July 8, 20204 yr Author Solution Found ! {{if $item->object() instanceof \IPS\cms\Records}} <div class="ipsType_richText ipsType_medium ipsSpacer_both">{$item->object()->customFieldDisplayByKey('1001bd_Note')|raw}</div> {{endif}} I have exaclty what I want without error 🙂