Sign In  |  Cart  |  Join Now

BlockView::getBlockURL() and BlockView::getBlockPath() don't work with $filename param

January 30, 2010
Status: New
Priority: Low

How important is this to you?

Very
Somewhat
Not important
Please Login to Vote
Passing a $filename argument to the getBlockPath() or getBlockUrl() functions in concrete/libraries/block_view.php should return a path that has that filename appended to it (as per the getBlockUrl function comments: "Returns a relative path to the current block's directory. If a filename is specified it will be appended and searched for as well.")

However, it does not do this. Looking at version 5.3.3.1, line 109 should be this:
<?php  
$base 
DIR_FILES_BLOCK_TYPES '/' $obj->getBlockTypeHandle() . '/' $filename;
 
?>


and line 131 should be this:
<?php  
$base 
DIR_REL '/' DIRNAME_BLOCKS '/' $obj->getBlockTypeHandle() . '/' $filename;
 
?>


Patch is attached.

I'm confused

Feb 01, 2010 at 12:05 PM
DIR_FILES_BLOCK_TYPES evaluates to

DIR_BASE . '/blocks' which should be the same as DIR_REL . '/blocks/'. Is there something non-standard about your setup? Is the problem perhaps somewhere else in the inclusion process?
 

The problem is with the $filename param

Feb 01, 2010 at 3:30 PM
The issue isn't with the path, it's that the function signature and the comments describing it say that passing a $filename argument should append that filename to the path, but the function is not appending the filename to the path.
 

Ah

Feb 01, 2010 at 3:54 PM
No, the function has always been meant to return the URL or path up to but not including the filename. That's because this actually used to not include the filename as a parameter, and it was strictly for returning a path. However, the filename was added because it's possible for concrete5 to override core files by placing them in the local directory. This function then checks based on filename whether it should be looking in the local directory or in the core. But the function was always meant to have no filename at the end.

If you're looking for a function to use within the context of a block view that will include the file as well, you should try BlockView::inc(). Like so:

<?=$this->inc('some_file.php'); ?>

It will also make sure that the various sets and controller helpers, etc... are available in the local context of the included file.
 
 

Hot Spots...

ForumsPartners | Contact | Blog

Search site