Theme path from a block view?
Permalink 4 users found helpful
I'm not sure I'm thinking about this correctly, but is it possible to get the theme path from a Block view?
I have created my own Block, but I can't seem to figure out how to get to any assets within the current theme's directory.
I have created my own Block, but I can't seem to figure out how to get to any assets within the current theme's directory.
I'm an idiot. to early.lol you want the Theme path from a block view.
you should be able to call the theme path as normal from the controller, and then grab it from your block view.
and then in your controller:
you should be able to call the theme path as normal from the controller, and then grab it from your block view.
$thempath = $controller->getTheme(); echo $themepath;
and then in your controller:
function getTheme(){ $theme = $this->getThemePath(); return $theme; }
Ahhhh... okay. That's what I was doing wrong. I was trying to call the getThemePath method on the Block's view.
What's strange is that it didn't throw an exception or an error, it just produced nothing.
So getThemePath is a method of the controller?
What's strange is that it didn't throw an exception or an error, it just produced nothing.
So getThemePath is a method of the controller?
getThemePath is a function from the view object. View::getThemePath(); should work, but doesn't seem to work from within block views. Seems to me like the block views aren't theme aware which is kinda odd...
I tried it in the controller, but just got an error because the method isn't available from within the controller - only the view...
Anyone know a way around this?
Jon
I tried it in the controller, but just got an error because the method isn't available from within the controller - only the view...
Anyone know a way around this?
Jon
getThemePath is a function from the view object. View::getThemePath(); should work, but doesn't seem to work from within block views. Seems to me like the block views aren't theme aware which is kinda odd...
I tried it in the controller, but just got an error because the method isn't available from within the controller - only the view...
Anyone know a way around this?
Jon
I tried it in the controller, but just got an error because the method isn't available from within the controller - only the view...
Anyone know a way around this?
Jon
$v = View::getInstance();
$v->getThemePath();
That'll work...
:)
$v->getThemePath();
That'll work...
:)
good call.
my bad.
thanks for sharing!
my bad.
thanks for sharing!
Not to get hung up on design patterns or anything... but is there a reason for not having the themepath directly accessible within the Block view?
Is it considered "bad form" to have Block assets stored within a theme?
My original reason for wanting this method was because I didn't know the best place to store an image element that I'm using in my Block (just a button skin actually).
Thanks for all the great help!
Is it considered "bad form" to have Block assets stored within a theme?
My original reason for wanting this method was because I didn't know the best place to store an image element that I'm using in my Block (just a button skin actually).
Thanks for all the great help!
that's just for the block root.
if you want to add subfolder location info from your block, simply concatenate directory info: