get block path from within block controller

Permalink
Is it possible to get the block path from the blocks controller?


basicly need something like below, however i get an error.
$layout_dir = Block::getBlockPath() . '/layouts/';


Error
Fatal error: Call to undefined method Slickslider2BlockController::getPackageID()


I haven't asked it to run getPackageID any were. I assume it is in the Blocks class

mikeyt55
 
hutman replied on at Permalink Reply
hutman
You could use this

$layout_dir = dirname(__FILE__) . '/layouts/';


If you were going to use it in the view.php you could use

$layout_dir = $this->getBlockPath() . '/layouts/';
JohntheFish replied on at Permalink Reply
JohntheFish
If you can explain a bit more about your overall objective, there could be a better way to do it.
mikeyt55 replied on at Permalink Reply
mikeyt55
trying to get the files within the folder layouts, that is within the block folder
JohntheFish replied on at Permalink Reply
JohntheFish
I think we have already gathered that. Please explain further so we have the big picture.
mikeyt55 replied on at Permalink Reply
mikeyt55
well that's all I want to do lol, what is it you want to know?
JohntheFish replied on at Permalink Reply
JohntheFish
Sometimes if a developer is doing something that is difficult within the existing api, its because the overall way things are structured in what they are doing is inappropriate. Along the lines of the driver who stops to ask directions and gets the answer "Well, I wouldn't start from here".
mikeyt55 replied on at Permalink Reply
mikeyt55
How would you suggest I get the files within a folder then, If there is another way that would be great.