Search code examples
concrete5

Concrete5 - Can I get the package icon inside a tool?


I have a tool inside my package (it is a loopback page which will be displayed at the end of an external authentication flow).

The page should display the package icon but because the base is an unusual URL I can't get anything relative to it and I'm not sure how I can get the icon.

URLHelper:getPackageIcon($pkg) no longer exists but if I can get the package object I'm sure I can still get the URL for the icon but I'm not sure how to get the package either.

I already tried the following

$package = Package::getByID($this->getPackageID());
$package_path = BASE_URL . $package->getRelativePath() . '/icon.png';

Solution

  • the tool is not aware of the package object. $this will be a view object.

    $pkg=Package::getByHandle('my_package_handle');
    $icon_url = $pkg->getRelativePath(). '/icon.png';
    

    You may also be able to get away without BASE_URL.