Page 1 of 1

“top” parameter in {cms_filepicker} changes output path?

Posted: Fri Apr 19, 2024 2:36 pm
by 10010110
So, I have hero images in a directory called “hero” inside the uploads directory. I’m using this template tag:

Code: Select all

{content_module module='ECB2' block='filepicker' field='file_picker' top='hero' assign='hero'}
Since ECB2 is just extending the default FilePicker module, I can use the “top” parameter of {cms_filepicker} to specify a top directory, and this works on the admin side but the output of that tag doesn’t seem to take that into account. If I echo

Code: Select all

{$hero}
I’m just getting the file name, no path prepended. If I leave the top parameter out I can/have to change the directories while selecting a file and then it prints the proper file path with parent directories. Am I missing something? I would assume it should always print the complete file path relative to the uploads directory and the top parameter only specifies the topmost browsable directory in admin?

Re: “top” parameter in {cms_filepicker} changes output path?

Posted: Fri Apr 19, 2024 3:34 pm
by DIGI3
Using a filepicker profile or the top parameter will cause the ECB2 tag to only store the path and filename relative to that profile or top directory. It assumes you know the path you defined in the tag, so you also use that path in your templates to display the file.
e.g. if you use

Code: Select all

{content_module module=ECB2 field=file_picker block=test assign=tempfile top='foobar'}
Your template would be something like

Code: Select all

<img src="{uploads_url}/foobar/{$tempfile}">

Re: “top” parameter in {cms_filepicker} changes output path?

Posted: Fri Apr 19, 2024 5:31 pm
by 10010110
Thanks for the quick answer. :)