Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 10    Views: 62

tompos
Veteran developer
Profile
Posts: 127
Reg: Oct 19, 2013
Würzburg
7,370
02/13/15 04:50 AM (9 years ago)

DateTime Picker in Control Panel

Hi, I am currently developing a plugin where date/time information for an event can be typed into the control panel for an app. As the error handling with such inputs may get complicated I thought about using some open-source javascript/jquery solutions in the control panel. However, I am not sure whether it is possible to add such external scripts & libraries into a Buzztouch plugin. I guess that you might perform some rather weird modifications to the Buzztouch control panel interface... and this may be a good reason to block such third-party scripts from the Buzztouch system. Any ideas? Best wishes Thomas
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
02/13/15 08:25 AM (9 years ago)
You betcha. It's not simple, but it's not 'that' difficult. I found some half decent javascript source here: http://www.javascriptkit.com/script/script2/tengcalendar.shtml And putting the javascript source code and the cal.gif (calendar image) into the plugin directory, modify your 'section' code similar to this: https://dl.dropboxusercontent.com/u/115208762/sw_test_genericText.html.zip and you should be humming in almost no time. Cheers! -- Smug
 
tompos
Veteran developer
Profile
Posts: 127
Reg: Oct 19, 2013
Würzburg
7,370
like
02/14/15 05:49 AM (9 years ago)
Thanks, Smug, the inclusion of the code into the html-file was straightforward. The problem with this solution was similar to my problems with other open source datepickers. The error console of my browser reports Internal Server Errors (500) for each .js-file I tried to include, like [Error] Failed to load resource: the server responded with a status of 500 (Internal Server Error) apps.thomasmeigen.de/files/plugins/TH_TestPlugin/cal.gif [Error] Failed to load resource: the server responded with a status of 500 (Internal Server Error) apps.thomasmeigen.de/files/plugins/TH_TestPlugin/datetimepicker.js I uploaded the .js-file and the cal.gif file into my plugin directory, they have the same read/write/execute permissions as all other files. Even if I set them to 777 the same 500-errors occur. Thus I thought that an inclusion of such js-files might be prohibited by the Buzztouch system.. But I guess that I have some more basic problems with my self-hosted server. Best wishes and thanks again Thomas
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
02/14/15 06:22 AM (9 years ago)
Maybe... All I can say is that it worked ok on my self hosted setup. Is it *your* server or a hosted setup? It is all the javascripts, or just that type? Have you tested with a custom plugin in your BT hosted account? That may (or may not) help to narrow down the culprit. Cheers! -- Smug
 
tompos
Veteran developer
Profile
Posts: 127
Reg: Oct 19, 2013
Würzburg
7,370
like
02/15/15 05:57 AM (9 years ago)
Yes, other custom plugins work fine. These server errors occurred the first time when I tried to include other .js-files from my .html files. If I include some javascript into the .html files there are no problems. It is not *my* server, I tested it on my domain which is hosted by Hostgator. Perhaps I should ask the Hostgator support about these server errors. I might try to setup a local server in my office to run the Buzztouch self-hosted-server software. However, I suspected that there would be a more basic problem with my inclusion of Javascript files. What do you mean by "It is all the javascript, or just that type"? All links to external files (datetimepicker.js, cal.gif) led to the same server errors. Thanks again Thomas
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
02/15/15 06:28 AM (9 years ago)
I was wondering if you had issues with 'all' javascript, or just that particular script. It seems a little odd that it would bark at 'both' the gif and the javascript file... Perhaps you might want to re-check the path. When I did mine, I had to put the entire URL because I couldn't figure out the correct 'relative' path, and putting the URL in fixed my issue. I can see it barking at the Java OR the gif, but both is a little odd. Basically what I did was work on it until the gif appeared, and used the same path format for the javascript as well. Or it might be hostgator, But I can't be sure; I use a different hosting service. Cheers! -- Smug
 
tompos
Veteran developer
Profile
Posts: 127
Reg: Oct 19, 2013
Würzburg
7,370
like
02/15/15 12:57 PM (9 years ago)
Thanks Smug, your idea to check the path made the difference. I had to include the "/BT-server" part in the path to the Javascript and gif files, then it worked. /BT-server/files/plugins/... What is surprising is the fact that you did not have to include the "/BT-server" part in your example. So perhaps the Root-URL of our self-hosted servers differ in their settings. On my self-hosted server the "Application Root URL" is set to "http://apps.thomasmeigen.de/BT-server", so I do not understand why an additional inclusion of "/BT-server" is necessary. ... while my problem is solved, it may come back when I upload my files to the plugin market. Originally, I thought that I would not need any path information as the .js and .gif files are in the same directory as my .html file. However, when I try to include them without a path, the Server Error (500) relates to /BT-server/bt_v15/bt_app/datetimepicker.js So /BT-server/bt_v15/bt_app seems to be the current directory when the error occurs. I might try to give all paths relative to this directory. However, I would like to understand it... Thanks again, Smug! Thomas
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
02/15/15 03:43 PM (9 years ago)
Oh, well the reason I don't include "BT-server" in my path is that it's not part of my path :) With respect to "come back when I upload for the market", that doesn't have to be true. Remember in your config.php file (in the root of your server) there are several 'constants' that are defined, such as: define("APP_DATA_DIRECTORY", "/files"); define("APP_URL", "http://www.yourserver.com"); It might take some playing around, but I bet they could be worked in to allow 'dynamic' access to someone's plugin directory. maybe something like <?php echo(APP_DATA_DIRECTORY);?>/plugins/ might work? And I agree; sometimes it's a little confusing where the paths take us. The initial index.php then grabs stuff from several directories, and it's hard to determine which one works for which situations. That's why I ended up using a full path during testing... proof of concept. Cheers! -- Smug
 
tompos
Veteran developer
Profile
Posts: 127
Reg: Oct 19, 2013
Würzburg
7,370
like
02/16/15 01:08 AM (9 years ago)
A lot of good ideas, thanks Smug! Yes, it might be best to get the information from those general settings in config.php. In the current case, my APP_DATA_DIRECTORY points to "/files" as well. So the attempt to find my files via <?php echo(APP_DATA_DIRECTORY);?>/plugins/... would have failed with the same server error, but I got the point. My "APP_URL" points to "http://apps.thomasmeigen.de/BT-server" and a combination of both constants might do the trick. As it is hard to tell where we are (in terms of directories within the BT-server tree), I learn from your response that there is no "documented best practice" to include additional files for the control panel? Thanks again Thomas
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
02/16/15 02:13 AM (9 years ago)
Until I hear something official from David, 'Best Practice' is the one that works consistantly, lol! :) But I think you're almost there, if you haven't finished it already. I think you're right; a combo of the two should probably cover your bases. "my" server filepath is 'http://www.myserver.com' and from there, everyone 'should' have a files/plugins/yourPluginName path, unless 'they' have done some modification. So the theory is 'it should work'. Even your different appUrl should reflect the correct path 'prefix', so fingers crossed. If someone did alter their paths and such, either they already know something needs to be modified, or they've botched things up and will end up reinstalling anyway... I think your practice is about as 'Best' as can be expected under current conditions. All it will take is an install or two on someone elses servers to be sure. And you could also try it out on your own BT Hosted account to be rock sure. Cheers! -- Smug
 
tompos
Veteran developer
Profile
Posts: 127
Reg: Oct 19, 2013
Würzburg
7,370
like
02/16/15 05:06 AM (9 years ago)
Yes, Smug, I finished it with a combination of the 2 constants. Thanks again... testing my plugin on my own BT hosted account is in fact the best final test... Anyway, I learned a lot from your help! Amazing! (and perhaps we might have triggered some reaction from David. But he must be very busy with his farewell ceremony for the orange color...) Cheers Thomas
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.