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
How do I obtain the location or URL of the tools folder for a block?
Is this documented?
Jake
Where exactly are you trying to add the link? from controller, view/template, add, edit, or somewhere else?
what if you are working with template of this block?
is it bad practise to create tool directory in block's template folder?
is it bad practise to create tool directory in block's template folder?
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...
http://www.concrete5.org/developers/bugs/5-5-2/blockviewtemplateget...
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:
For a file in a package's tools directory, do this:
For a block's tools file, I think you do this:
...or use 12345j's solution because it's way simpler :)
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 :)
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)