Invision Community 4: SEO, prepare for v5 and dormant account notifications By Matt Monday at 02:04 PM
Poseidon2 Posted July 8, 2020 Posted July 8, 2020 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
Poseidon2 Posted July 8, 2020 Author Posted July 8, 2020 In fact I don't know how to go from $item to the full record that is currently shown....
bfarber Posted July 8, 2020 Posted July 8, 2020 $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.
Poseidon2 Posted July 8, 2020 Author Posted July 8, 2020 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 ?
Poseidon2 Posted July 8, 2020 Author Posted July 8, 2020 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 ?
Solution Poseidon2 Posted July 8, 2020 Author Solution Posted July 8, 2020 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 🙂
Recommended Posts