url when using alternate template

Permalink
I'm trying to create a new template for a block. I created a new folder called templates in the block folder, created a folder with the template name then copied the view.php into the folder... only problem is the view.php file is breaking because it's not pointing to the "root" anymore.
so using
$baseURL = $bvt -> getBaseURL ();
now points to /packages/addon/blocks/addon/templates/newtemplate instead of /packages/addon/blocks/addon

I'm sure there's a simple way to point the new template to the block root, just don't know how. thanks

jleinbaugh
 
jordanlev replied on at Permalink Reply
jordanlev
Not sure I understand the exact scenario -- you are creating a package that has a custom template in it, correct? Does this custom template override one of the built-in C5 blocks, or is it an additional template for a block that's also in the package?

And what exact URL are you trying to get? (The root to the original block directory? Or the root to the overridden template?)
jleinbaugh replied on at Permalink Reply
jleinbaugh
Sorry to be vague... I'm using the Media Library addon. I wanted to create a custom template to display videos differently then the main (only) view.php so I made a templates folder in the block folder and copied the original view.php from the block into templates/newtemplate folder

but the original view.php uses the above code (getBaseURL) so the block won't load the videos (and I assume is not loading the flash player) because the new template view is no longer in the block folder, but two layers deeper (instead of block/view.php it's block/tempates/newtemplate/view.php) so I was hoping there was a simple way to point the new view.php back to the addon root so it picks up the js and flash correctly...

does that make any more sense?
jordanlev replied on at Permalink Reply
jordanlev
Hmm... that's a paid addon so I can't see the code. Did you try asking the developer for support on this?

Off the top of my head, you want might try using the getBlockURL() method of the BlockView instead of the getBaseURL of the BlockViewTemplate. Not sure how this fits in with the existing code, but I use this in my block controllers often:
$bv = new BlockView();
$bv->setBlockObject($this->getBlockObject());
$blockURL = $bv->getBlockURL();


And if that doesn't work you can always cheat and just hardcode the path to your block:
DIR_REL . '/blocks/media_library/templates/newtemplate/style.css


-Jordan