Apply Jquery Effect to Block That's Included With a Theme

Permalink 1 user found helpful
So, umm, like yeah... I am working on some relatively simple blocks that will be included with a theme that I'm working. I need to apply a jquery effect to them. I want to do it in such a way that I could possibly release them as stand-alone blocks in the marketplace.

What's the best way to go about doing this?

PineCreativeLabs
 
12345j replied on at Permalink Reply
12345j
in the blocks controller
public function on_page_view() {
          $html = Loader::helper('html');
           $this->addHeaderItem($html->javascript('myjsfile.js'));
      }

will load the js file in root/js/myjsfile.js
PineCreativeLabs replied on at Permalink Reply
PineCreativeLabs
Thanks! That worked just dandy for me!

Does this method also work for adding a stylesheet? If so, what would be the markup for that?

My block works so far, except for when you go back to edit it, the text does not show. What would cause that?
noXstyle replied on at Permalink Reply
noXstyle
You can append stylesheets in similar fashion by using css method:

$html = Loader::helper('html');
$this->addHeaderItem($html->css('mycssfile.css'));


both methods take $pkgHandle as a second argument so if you're packaging the block for marketplace the js/css file will be loaded from packages/yourpackage/css or js...

Can you be a bit more specific on the edit problem? Are you able to edit the block even though the text doesn't show? How are you outputting the contents in view.php?