How to get tools folder for a block

Permalink 3 users found helpful
Hi

How do I obtain the location or URL of the tools folder for a block?

Is this documented?

Jake

BinaryFold4
 
jelthure replied on at Permalink Reply
jelthure
Where exactly are you trying to add the link? from controller, view/template, add, edit, or somewhere else?
12345j replied on at Permalink Reply
12345j
<?php echo $this->getBlockURL() ?>/
gets the block path- do
<?php echo $this->getBlockURL() ?>/tools/
to get the tools url
eOne replied on at Permalink Reply
what if you are working with template of this block?
is it bad practise to create tool directory in block's template folder?
jordanlev replied on at Permalink Reply
jordanlev
I don't know. Custom templates are tricky. I'm honestly not sure what the rules surrounding it are, and I have tried to get the core team to clarify this but they don't seem to understand the problem -- for example, see here:
http://www.concrete5.org/developers/bugs/5-5-2/blockviewtemplateget...
jordanlev replied on at Permalink Best Answer Reply
jordanlev
Is this in a package or just a block you have in your site?

You want to use the urls helper.

For a file that's in your site's top-level tools directory, do this:
echo Loader::helper('concrete/urls')->getToolsURL('name_of_tools_file_without_php_at_the_end');


For a file in a package's tools directory, do this:
echo Loader::helper('concrete/urls')->getToolsURL('name_of_tools_file_without_php_at_the_end', 'your_package_handle');


For a block's tools file, I think you do this:
Loader::model('block_types');
$bt = BlockType::getByHandle('your_block_handle');
$tools_dir = Loader::helper('concrete/urls')->getBlockTypeToolsURL($bt);
echo $tools_dir . '/name_of_tools_file_without_php_at_the_end';

...or use 12345j's solution because it's way simpler :)
12345j replied on at Permalink Reply
12345j
yeah, you want to use jordans code for blocks if you're calling from a controller, the code I posted only works in view(i think)