Using images in packages1 user found helpful
I'm extending a package and just want to generate some HTML to use an image that is part of the package. The image is in the folder named
I just need to generate some HTML that says <img src="imagepath">
But what is the imagepath? Do I need to call getRelativePath on something, or can I just hard-code it in there? If the former, what object do I call getRelativePath on; if the latter, what is the correct path to put in there?
$c = Page::getCurrentPage(); // this was already there
$pkh=$bks->getPackageHandle(); // there will only ever be the one
That's where I sort of stalled again. Sorry, this is all uncharted territory for me.
// Get the package relative path
$pkid=$bks->getPackageID(); // can only do this if only 1 block in 'Main'
I can then put $ppath in my HTML as required.
This may not be the "best" way to do this, but it works.
$package = Package::getByID($obj->getPackageID()); $package_path = BASE_URL . $package->getRelativePath() . '/'; $block_path = $package_path . "blocks/" . $obj->btHandle . '/';
to obtain the package path and block path, respectively.