How do I get resource logo?

LPH

Well-known member
A var_dump isn't showing a way to get the resource logo. Am I missing something obvious?

PHP:
        /**
        * Script to pull the latest updated resources from the XF Resource Manager
        * @var $resModel  XenResource_Model_Resource
        */
        $resModel = XenForo_Model::create( 'XenResource_Model_Resource' );

        // @todo Make options
        $fetchOptions = array( 'limit' => 5, 'order' => 'resource_date', 'direction' => 'desc' );

        $rmupdates = $resModel->getResources( array(), $fetchOptions );

        var_dump($rmupdates);

The above script pulls the title and I can link to it but cannot figure out a way to retrieve the logo / icon. In fact, looking at the database does not show a logo field logo_width and logo_height.

Screen Shot 2016-03-13 at 10.14.43 AM.webp
 
Last edited:
Ugh. A 1 is getting stuck in the path.

PHP:
 $resourceId = $rmupdate['resource_id'];
 echo '<span class="resource_icon"><img src=' . XenWord::getBoardUrl() . '/data/' . $resModel->getResourceIconFilePath($resourceId, $externalDataPath = true) . '/></span>';

It's returning http://domain/community/data/1/resource_icons/0/1.jpg

The 1 should definitely not be in the path.
 
True equals 1 in binary. In other words: you're using the $externalDataPath-Variable wrong. It does not expect a boolean value but the actual path. So you'd need to do the following:

PHP:
echo '<span class="resource_icon"><img src=' . $resModel->getResourceIconFilePath($resourceId, XenWord::getBoardUrl() . '/data/') . '/></span>';
 
True equals 1 in binary. In other words: you're using the $externalDataPath-Variable wrong. It does not expect a boolean value but the actual path. So you'd need to do the following:

:censored:

You are correct. I had to remove the extra / after data and before the >. Interestingly, this does not show the icon on a local dev environment (MAMP) but shows fine on a live site.

PHP:
echo '<span class="resource_icon"><img src=' . $resModel->getResourceIconFilePath($resourceId, XenWord::getBoardUrl() . '/data') . ' width="36px"></span>';

It's better than what I initially built:

PHP:
echo '<span class="resource_icon"><img src=' . XenWord::getBoardUrl() . '/data/resource_icons/' . $floor . '/' . $resourceId . '.jpg' . ' width="36px"></span>';
 
Back
Top Bottom