Sharing Assets for multiple blocks in Packages

Permalink
Hi guys,

I'm building my first package and was wondering how I would go about having a common assets folder within a package for each block to source from.

Is there something similar to BlockType::getByHandle(handle) but instead I could get the path to the directory of the package in which I could just paste into the blocks? I am essentially using images and stylesheets only in the form_setup_html.php file.

Thanks in advance
Ritchie

 
jordanlev replied on at Permalink Best Answer Reply
jordanlev
You could just include an "images" and "css" directory at the top-level of the package, and refer to them in your block code with:
$img_src = BASE_URL . DIR_REL . '/packages/your_package_handle/images/your_image_name.jpg'
$css_href = BASE_URL . DIR_REL . '/packages/your_package_handle/css/your_stylesheet.css'

This website stores cookies on your computer. These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media. To find out more about the cookies we use, see our Privacy Policy.