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

Official support hours:
Monday To Friday
From 09:00 To 17:00 Europe/London (BST)

Please post your question in the Forum and we will get back to you as soon as we can.

  Friday, 15 October 2021
  18 Replies
  890 Visits
Hello, i'm using your custom fiel "JCE File Browser" to add files to an article. I would like to override the layout (now is "default") to show the files in a specific way. How can i override it? Or add a new layout?
Thank you.
more than a month ago
·
#109100
The layout of the JCE File Browser cannot be overriden, as it does not use the Joomla View and Layout system.

Just because you're not paranoid doesn't mean everybody isn't out to get you.

more than a month ago
·
#109102
Ok thanks, but i can see that it has the option as others fields to choose the layout (see attachment). Is there a way to add a new one instead of overriding the existing one? I have to upload CSV but i don't need them to be downloadable but to show the contents in the article itself.
Thanks
more than a month ago
·
#109103
Apologies I misunderstood, I though you were referring to the layout of the File Browser window itself.

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.

Just because you're not paranoid doesn't mean everybody isn't out to get you.

more than a month ago
·
#109106
Thanks!
Can you please write me the full path of the override i have to insert in my /template/MYTEMPLATE/ folder?
Thank you
more than a month ago
·
#109107
It might be - templates/MYTEMPLATE/html/layouts/joomla/form/field/mediajce.php

Just because you're not paranoid doesn't mean everybody isn't out to get you.

more than a month ago
·
#109108
It works if I modify directly the file mediajce.php in /plugins/fields/mediajce/tmpl
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
more than a month ago
·
#109111
Sorry, wrong path.

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.

Just because you're not paranoid doesn't mean everybody isn't out to get you.

more than a month ago
·
#109112
Getting closer, but really sorry to bother you again.
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):

Cattura.JPG

the problem is that with the original file i get blank results. No output in the article. With default selected:

Cattura1.JPG

With override selected:

Cattura2.JPG

The file is the same, what can cause the problem?
Thanks
more than a month ago
·
#109113
Add the following to the top of the mediajce.php file (after jimport('joomla.filesystem.path');)


if (!key_exists('field', $displayData))
{
return;
}

$field = $displayData['field'];
$fieldParams = $field->params;

Just because you're not paranoid doesn't mean everybody isn't out to get you.

more than a month ago
·
#109114
Still not working, sorry
more than a month ago
·
#109115
It's working in my tests.

What other changes have you made to the mediajce.php file?

Just because you're not paranoid doesn't mean everybody isn't out to get you.

more than a month ago
·
#109116
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

Just because you're not paranoid doesn't mean everybody isn't out to get you.

more than a month ago
·
#109117
None, is the original one from rom plugins/fields/mediajce/tmpl/ to templates/protostar/html/layouts/com_fields/field/ and added the lines of code:

Cattura.JPG
more than a month ago
·
#109118
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


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?
more than a month ago
·
#109119
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.

Just because you're not paranoid doesn't mean everybody isn't out to get you.

more than a month ago
·
#109120
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.


Great, thanks! Let me know,
G.
more than a month ago
·
#109124
There appears to be some kind of Joomla bug where it processes the field trhough the default layout file first anyway, even if you have set an alternative. This happens even when using the core Media field.

So to get around this, we need to create a custom override that test for this, eg:


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="/%s"%s alt="%s" />';

// not an image, so create a link
if (!preg_match('#\.(jpeg|jpeg|png|gif)$#', $value)) {
$element = '<a href="/%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;

Just because you're not paranoid doesn't mean everybody isn't out to get you.

more than a month ago
·
#109132
it works! Thanks!
  • Page :
  • 1
There are no replies made for this post yet.
Be one of the first to reply to this post!