You are not logged in.
Pages: 1
Solved it. The selector for the Javascript to handle the media browsing, on file input change, etc. is:
.container form
So make sure your form is inside a element with the class of "container"!
Awesome, thanks Tim! And good point on the is_array, I totally missed that it was checking to see if it was a sub-array, so yeah, need two checks!
Maybe not so much a bug persay, but something noticed. It looks like the URL for a file uploaded to a service (at least for S3 and Google) is hard-coded as "http://.." in cloud-storage.php. Consider changing to "https://.." for compatibility with SSL sites, or even better, just "//.." so http/https isn't forced and the browser can just pull the image accordingly.
A few things I'm noticing after upgrading to 4.2:
1. When running "BigTreeAdmin::processField($field)" on a file upload, if I don't specify $field["options"]["crops"] as an array, I get an error: "Warning: Invalid argument supplied for foreach() in /home/uccms/public_html/core/inc/bigtree/admin.php on line 6077". Looking at line 6077 the code is:
// Handle Crops
foreach ($field["options"]["crops"] as $crop) {
if (is_array($crop)) {
And I think it should be reversed to:
// Handle Crops
if (is_array($crop)) {
foreach ($field["options"]["crops"] as $crop) {
To make sure it's an array first, before trying to loop through it.
2. When I specify a CSS file in settings.php, ex:
$bigtree["config"]["admin_css"] = array('custom.css');
It works just fine in the main admin areas, but if I go into my module (which is part of an extension I built), the URL of that file changes from:
<link rel="stylesheet" href="http://domain.com/admin/css/custom.css" type="text/css" media="screen" />
to
<link rel="stylesheet" href="http://domain.com/admin/*/com.extension.name/css/custom.css" type="text/css" media="screen" />
Even though it's specified as a global admin CSS file, and not an extension-specific CSS file using $bigtree['css'][].
Thanks!
In the case of "drawing" the field, is that something I could piggy-back on too? I have the code:
$field = array(
'title' => '', // The title given by the developer to draw as the label (drawn automatically)
'subtitle' => '', // The subtitle given by the developer to draw as the smaller part of the label (drawn automatically)
'key' => 'image', // The value you should use for the "name" attribute of your form field
'value' => '', // The existing value for this form field
'id' => 'category_image', // A unique ID you can assign to your form field for use in JavaScript
'tabindex' => '', // The current tab index you can use for the "tabindex" attribute of your form field
'options' => array(
'image' => true
),
'required' => false // A boolean value of whether this form field is required or not
);
include(BigTree::path('admin/form-field-types/draw/upload.php'));
Is there a shortcut function to do something similar, or is this the best practice?
Also, it displays the options of both Upload or Browse. When I click the Upload button it allows me to browse my computer like a normal file upload, but when I click the Browse button nothing happens. I'm guessing there has to be some supplemental JS to go along with it (and maybe the shortcut function includes it, or if not, what do I need to include for that)?
Sorry for all the questions, just trying to make sure we develop this module the best way possible. Thanks!
Awesome, I'll give this a try. Thanks Tim!
I'm building a custom module (my own code in /custom/admin/modules/module-name/) and trying to follow BigTree's existing code base as much as possible, and am trying to figure out how to handle a image / file upload through the module.
Of course I can do an <input type="file" /> and move_uploaded_file(), but I want to stay within the realm of BigTree to maintain compatibility, take advantage of the cloud storage integrations, etc.
I see some stuff in /core/admin/form-field-types/(draw/process)/upload.php, but I don't think they're meant to be accessed directly.
How should I go about this to leverage the cool and useful code BigTree already has? Thanks!
Pages: 1