1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How do I get resource logo?

Discussion in 'XenForo Development Discussions' started by LPH, Mar 13, 2016.

Tags:
  1. LPH

    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.png
     
    Last edited: Mar 13, 2016
  2. Chris D

    Chris D XenForo Developer Staff Member

    Is there anything in the Resource model that may help...?
     
  3. LPH

    LPH Well-Known Member

    As always, thank you Chris. The Model has getResourceIconFilePath. I'll play around with that method and see what can be done.
     
  4. LPH

    LPH Well-Known Member

    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.
     
  5. katsulynx

    katsulynx Well-Known Member

    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($resourceIdXenWord::getBoardUrl() . '/data/') . '/></span>';
     
  6. LPH

    LPH Well-Known Member

    :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($resourceIdXenWord::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>';
     

Share This Page