XF 2.0 How do you get attachments to show up in bb_code for content?

Jaxel

Well-known member
Working on my wiki software right now. Wiki pages can have their own attachments in my software. I've imported the data from the XF1 version, so my pages already have attachments linked to them.

First I get my page:
Code:
$wiki = $this->assertPageExists($params->page_slug, ['Thread']);

Then I fetch attachments linked to said page, and hydrate the relations:
Code:
$attachments = $this->finder('XF:Attachment')
    ->where('content_type', 'ewr_carta_page')
    ->where('content_id', $wiki->page_id)
    ->order('attach_date')
    ->fetch();

$wiki->hydrateRelation('Attachments', \XF::em()->getBasicCollection($attachments->toArray()));
This clearly works, as when I dump the $wiki variable, I can see the attachment relations.


However, if I then parse the bb_code:
Code:
$html = \XF::app()->bbCode()->render($wiki->page_content, 'html', 'ewr_carta_page', $wiki);

\XF::dump($html);


Instead of getting nice thumbnails where the [ATTACH]###[/ATTACH] should be, I am getting generic View attachment ### links.

What am I forgetting here?
 
Figured it out. Apparently, getBbCodeRenderOptions is not called when processing bbcode through php... only in templates.
 
Back
Top Bottom