Thank you.
You need to be logged in to post in the forum - Log In
An active JCE Pro Subscription is required to post in the forum - Buy a Subscription
Support is currently Offline
09:00 - 17:00 Europe/London (BST)
Please create a new Ticket and we will get back to you as soon as we can.
#109097 Custom field JCE File Browser layout override
This is a public ticket
Everybody will be able to see its contents. Do not include usernames, passwords or any other sensitive information.
Latest post by Ryan on Wednesday, 01 February 2023 10:42 GMT
Friday, 15 October 2021 09:27 BST
Thank you.
Friday, 15 October 2021 10:40 BST
Ryan Demmer
Lead Developer / CEO / CTO
Just because you're not paranoid doesn't mean everybody isn't out to get you.
Friday, 15 October 2021 10:42 BST
Thanks
Friday, 15 October 2021 10:47 BST
The layout file is located in plugins/fields/mediajce/tmpl/mediajce.php and so you can override it in the same way as you would the core Media Field, using a template override.
Ryan Demmer
Lead Developer / CEO / CTO
Just because you're not paranoid doesn't mean everybody isn't out to get you.
Friday, 15 October 2021 10:55 BST
Can you please write me the full path of the override i have to insert in my /template/MYTEMPLATE/ folder?
Thank you
Friday, 15 October 2021 10:57 BST
Ryan Demmer
Lead Developer / CEO / CTO
Just because you're not paranoid doesn't mean everybody isn't out to get you.
Friday, 15 October 2021 11:05 BST
but if i copy the php file and put it in /templates/protostar/html/layouts/joomla/form/field all modifications i made are ignored (i'm using the default protostart for testing purpose).
Do i have to activate the override somewhere in jce options?
Thanks
Friday, 15 October 2021 11:32 BST
Copy the mediajce.php file from plugins/fields/mediajce/tmpl/ to templates/protostar/html/layouts/com_fields/field/
Make the modifications you require.
You should then be able to select it as the Layout when creating the Field.
Ryan Demmer
Lead Developer / CEO / CTO
Just because you're not paranoid doesn't mean everybody isn't out to get you.
Friday, 15 October 2021 11:44 BST
I've copied the exact file mediajce.php here /templates/protostar/html/layouts/com_fields/field and actually i can see it in the fields layout options (see attachment):
the problem is that with the original file i get blank results. No output in the article. With default selected:
With override selected:
The file is the same, what can cause the problem?
Thanks
Friday, 15 October 2021 12:23 BST
if (!key_exists('field', $displayData))
{
return;
}
$field = $displayData['field'];
$fieldParams = $field->params;
Ryan Demmer
Lead Developer / CEO / CTO
Just because you're not paranoid doesn't mean everybody isn't out to get you.
Friday, 15 October 2021 12:30 BST
Friday, 15 October 2021 12:34 BST
What other changes have you made to the mediajce.php file?
Ryan Demmer
Lead Developer / CEO / CTO
Just because you're not paranoid doesn't mean everybody isn't out to get you.
Friday, 15 October 2021 12:37 BST
Ryan Demmer
Lead Developer / CEO / CTO
Just because you're not paranoid doesn't mean everybody isn't out to get you.
Friday, 15 October 2021 12:42 BST
Ok, so the only way to solve this right now is to modify the original in plugins/fields/mediajce/tmpl/ and remove the override and the re-apply the patch every time i update JCE?
Friday, 15 October 2021 12:43 BST
Ok I see the problem, but this looks like a Joomla bug to me, because it should be loading the original mediajce.php file if the Layout is set back to "Default", but instead it appears to be loading components/com_fields/layouts/field/render.php
No, I think I'm wrong about this, I'm looking into it.
Ryan Demmer
Lead Developer / CEO / CTO
Just because you're not paranoid doesn't mean everybody isn't out to get you.
Friday, 15 October 2021 13:39 BST
Ok I see the problem, but this looks like a Joomla bug to me, because it should be loading the original mediajce.php file if the Layout is set back to "Default", but instead it appears to be loading components/com_fields/layouts/field/render.php
No, I think I'm wrong about this, I'm looking into it.[/quotePost]
Great, thanks! Let me know,
G.
Saturday, 16 October 2021 11:51 BST
if (!key_exists('field', $displayData))
{
return;
}
$field = $displayData['field'];
$fieldParams = $field->params;
if ($field->value == '') {
return;
}
$value = $field->value;
// already processed...restart
if (strpos($value, '<') == 0) {
$value = $field->rawvalue;
}
$text = basename($value);
$text = htmlentities($text, ENT_COMPAT, 'UTF-8', true);
$buffer = '';
// example attributes...
$attribs = array('class=""');
$element = '<img src="https://www.joomlacontenteditor.net/%s"%s alt="%s" />';
// not an image, so create a link
if (!preg_match('#\.(jpeg|jpeg|png|gif)$#', $value)) {
$element = '<a href="https://www.joomlacontenteditor.net/%s"%s>%s</a>';
// add blank target for links
$attribs['target="_blank"'];
}
$buffer .= sprintf($element,
htmlentities($value, ENT_COMPAT, 'UTF-8', true),
implode(' ', $attribs),
$text
);
echo $buffer;
Ryan Demmer
Lead Developer / CEO / CTO
Just because you're not paranoid doesn't mean everybody isn't out to get you.
Monday, 18 October 2021 10:34 BST
Sunday, 29 January 2023 10:09 GMT
My goal is to override a pdf link to <a href="https://www.joomlacontenteditor.net/link/to/pdffile">{$fieldtitle}</a>
Tuesday, 31 January 2023 12:18 GMT
Ryan Demmer
Lead Developer / CEO / CTO
Just because you're not paranoid doesn't mean everybody isn't out to get you.
Tuesday, 31 January 2023 13:30 GMT
i think i put it in my article override
Wednesday, 01 February 2023 10:42 GMT
<?php
defined('_JEXEC') or die;
use Joomla\Utilities\ArrayHelper;
if (empty($field->value) || empty($field->value['media_src']))
{
return;
}
$value = $field->value['media_src'];
$text = basename($value);
$text = htmlentities($text, ENT_COMPAT, 'UTF-8', true);
$buffer = '';
// example attributes...
$attribs = array();
$element = '<img src="https://www.joomlacontenteditor.net/%s"%s alt="%s" />';
// not an image, so create a link
if (!preg_match('#\.(jpeg|jpg|png|gif)$#', $value)) {
$element = '<a href="https://www.joomlacontenteditor.net/%s"%s>%s</a>';
// add blank target for links
$attribs['target'] = "_blank";
}
$buffer .= sprintf($element,
htmlentities($value, ENT_COMPAT, 'UTF-8', true),
ArrayHelper::toString($attribs),
$text
);
echo $buffer;
Ryan Demmer
Lead Developer / CEO / CTO
Just because you're not paranoid doesn't mean everybody isn't out to get you.
Please wait
Your post is being submitted…