Override a package block view from within another package
Permalink
I would like to override a packages block view from within my own theme.
For example Vivid Simple Accordion
I have added a view file to packages/theme_name/blocks/vivid_simple_accordion/view.php
but this is not overriding packages/simple_accordian/blocks/vivid_simple_accordion/view.php
I take it i'm doing something wrong I'm guessing it has something to do with the path of the view.php within my theme package.
Any help would be appreciated :-)
For example Vivid Simple Accordion
I have added a view file to packages/theme_name/blocks/vivid_simple_accordion/view.php
but this is not overriding packages/simple_accordian/blocks/vivid_simple_accordion/view.php
I take it i'm doing something wrong I'm guessing it has something to do with the path of the view.php within my theme package.
Any help would be appreciated :-)
You can't override a block's view from your theme.
What you can do is assign a template to that view by default.
To do so you need to create your block's template (which is just a modified copy of the view) and add it in packages/simple_accordian/blocks/vivid_simple_accordion/templates/template_handle/view.php
Then, to make sure that block uses that template every time, you need to go to your page_theme.php and add
In this example, the template is inside a folder using the template handle as name. This is usually done if your template has more than just the view.php (JS files, CSS...)
If on the other hand your template only has the one PHP file, then you can do it like this
packages/simple_accordian/blocks/vivid_simple_accordion/templates/template_handle.php
And in page_theme.php
One last thing to keep in mind, the template will not apply to blocks already added to your pages. It will only apply to blocks you will add AFTER adding this code.
Hope this helps.