Jump to content

Recommended Posts

Posted

Hey

I have created a new block based on our picks and am modifying the display template.

The template loops through the promoted items like this:

    {{foreach $promoted as $item}}

However the loop doesn't explicitly expose the content type - for example, topic, post, image, gallery, etc.

The only place the content type surfaces is in a pre built block like this - which is difficult to parse.

{$item->objectMetaDescription |raw }

Does anybody know how I can list all the properties of item or item object so that I can pick out what I need?

Currently I am searching the item url for a known substring, so as to ascertain the content type 🤨.

Many thanks

Chris

 

 

Posted

var_dump on $item will provide:

  protected '_data' => 
    array (size=18)
      'id' => int 1
      'class' => string 'IPS\forums\Topic' (length=16)
      'class_id' => int 96
      'text' => string '{"internal":"In regard to money matters C\u00e6sar was entirely without principle. In his early years he borrowed vast sums on all sides, spent them recklessly, and seldom paid his debts save with further borrowed money. While still a young man he owed his creditors the sum of \u00a3280,000; and though most of this had now been paid off by means of the loot from the Gallic Wars, there had been times in his life when ruin stared him in the face. Most of his debts were incurred in the first place in buying fo'... (length=1089)
      'short_link' => string 'http://localhost/45X/index.php?/topic/96-motivational-genus-porzana/' (length=68)
      'media' => string '[]' (length=2)
      'added' => int 1619437470
      'scheduled' => int 1619437470
      'sent' => int 1619437472
      'added_by' => int 1
      'schedule_auto' => int 0
      'share_to' => string '["internal"]' (length=12)
      'images' => string '[]' (length=2)
      'returned' => string '{"internal":1619437472}' (length=23)
      'failed' => int 0
      'internal' => int 1
      'form_data' => string '{"internal":{"title":""}}' (length=25)
      'hide' => int 0

So $item->class will give you the class. For this example, IPS\forums\Topic.

Btw, I used this in promotePublicTableRow Core template. Not sure if $item in yours is the same.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...