Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 13    Views: 60

Redbullet
Aspiring developer
Profile
Posts: 42
Reg: Mar 05, 2011
Earth
3,170
02/21/14 07:26 PM (10 years ago)

JSON Snippet Calling screens from a Menu list does not load menu list

Hi anyone here who can help me on this JSON Snippet implementation. I have here the JSON Snippet: {"itemId":"Video1", "itemType":"BT_launchNativeApp", "itemNickname":"Screen1", "appToLaunch":"browser", "dataURL":"http://www.google.com"}, {"itemId":"Screen2", "itemType":"BT_launchNativeApp", "itemNickname":"Video2", "appToLaunch":"browser", "dataURL":"http://www.yahoo.com"} I made a Menu screen that calls it via DataURL, then I save that a text file and put in a public Dropbox location. I also have validated this on JSONlint. Here's the content of the file: { "Screenitems": [{"itemId":"Screen1", "itemType":"BT_menuItem", "loadScreenWithItemId":"Screen1", "titleText":"Screen1"}, {"itemId":"Screen2", "itemType":"BT_menuItem", "loadScreenWithItemId":"Screen2", "titleText":"Screen2"}] } The Menu does not load list of sub-menu, anything else that I need to do? Any help would be appreciated, thanks!
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
02/21/14 09:19 PM (10 years ago)
Did you do this manually? Although it may be valid 'json' I don't think it contains all valid 'values'. In particular "loadScreenWithItemId":"Screen2" (or screen 1) A screen ID is usually a GUID looking string about 24 characters long in random order… a unique identifier… Try using 'loadScreenWithNickname" instead, or maybe provide some more of your config file, but that's what it 'looks' like with the info given… Cheers! -- Smug
 
Redbullet
Aspiring developer
Profile
Posts: 42
Reg: Mar 05, 2011
Earth
3,170
like
02/21/14 09:42 PM (10 years ago)
Thanks Smug After debugging many times, I found out the importance of declaring and non-declaring of "childItems" on JSON data. For the menu declare "childItems" for the snippet do not declare. Now my menu works.
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
02/21/14 09:48 PM (10 years ago)
Json is an interesting challenge until it all sinks in… which for me, is yet to come. But slowly we trudge on. Glad you got it going! :) Cheers! -- Smug
 
Angry Ninja
Aspiring developer
Profile
Posts: 1045
Reg: Aug 25, 2013
Maine
17,150
like
02/21/14 10:29 PM (10 years ago)
Hey redbullet, Do you mind sharing the updated text file contents that worked for you? I just started trying to learn json a little better, and how to use json snippet keeper, and was watching this thread to see how your method worked. Would love to see the working text file if possible. Thanks. :)
 
Redbullet
Aspiring developer
Profile
Posts: 42
Reg: Mar 05, 2011
Earth
3,170
like
02/22/14 01:08 AM (10 years ago)
Sure Angry This is the JSON snippet {"itemId":"Video1", "itemType":"BT_launchNativeApp", "itemNickname":"Video1", "appToLaunch":"browser", "dataURL":"http://www.google.com"}, {"itemId":"Video2", "itemType":"BT_launchNativeApp", "itemNickname":"Video2", "appToLaunch":"browser", "dataURL":"http://www.yahoo.com"}, {"itemId":"Video3", "itemType":"BT_launchNativeApp", "itemNickname":"Video3", "appToLaunch":"browser", "dataURL":"http://www.cnn.com"}, {"itemId":"Video4", "itemType":"BT_launchNativeApp", "itemNickname":"Video4", "appToLaunch":"browser", "dataURL":"http://www.youtube.com"}, {"itemId":"Video5", "itemType":"BT_launchNativeApp", "itemNickname":"Video5", "appToLaunch":"browser", "dataURL":"http://www.inquirer.net"}, {"itemId":"Video6", "itemType":"BT_launchNativeApp", "itemNickname":"Video6", "appToLaunch":"browser", "dataURL":"http://www.samsung.com"}, {"itemId":"Video7", "itemType":"BT_launchNativeApp", "itemNickname":"Video7", "appToLaunch":"browser", "dataURL":"http://www.google.com"}, {"itemId":"Video8", "itemType":"BT_launchNativeApp", "itemNickname":"Video8", "appToLaunch":"browser", "dataURL":"http://www.google.com"}, {"itemId":"Video9", "itemType":"BT_launchNativeApp", "itemNickname":"Video9", "appToLaunch":"browser", "dataURL":"http://www.google.com"}, {"itemId":"Video10", "itemType":"BT_launchNativeApp", "itemNickname":"Video10", "appToLaunch":"browser", "dataURL":"http://www.google.com"} This is the text file { "childItems": [{"itemId":"Videoitem1", "itemType":"BT_menuItem", "loadScreenWithItemId":"Video1", "titleText":"Video1"}, {"itemId":"Videoitem2", "itemType":"BT_menuItem", "loadScreenWithItemId":"Video2", "titleText":"Video1"}, {"itemId":"Videoitem3", "itemType":"BT_menuItem", "loadScreenWithItemId":"Video3", "titleText":"Video1"}, {"itemId":"Videoitem4", "itemType":"BT_menuItem", "loadScreenWithItemId":"Video4", "titleText":"Video1"}, {"itemId":"Videoitem5", "itemType":"BT_menuItem", "loadScreenWithItemId":"Video5", "titleText":"Video1"}, {"itemId":"Videoitem6", "itemType":"BT_menuItem", "loadScreenWithItemId":"Video6", "titleText":"Video1"}, {"itemId":"Videoitem7", "itemType":"BT_menuItem", "loadScreenWithItemId":"Video7", "titleText":"Video1"}, {"itemId":"Videoitem8", "itemType":"BT_menuItem", "loadScreenWithItemId":"Video8", "titleText":"Video1"}, {"itemId":"Videoitem9", "itemType":"BT_menuItem", "loadScreenWithItemId":"Video9", "titleText":"Video1"}, {"itemId":"Videoitem10", "itemType":"BT_menuItem", "loadScreenWithItemId":"Video10", "titleText":"Video1"}] }
 
Angry Ninja
Aspiring developer
Profile
Posts: 1045
Reg: Aug 25, 2013
Maine
17,150
like
02/22/14 01:14 AM (10 years ago)
Awesome, thanks! Just started looking into json snippet keeper. Already over 500 screens deep into my app and not even halfway done. Hoping it can help save me some time with creating the redundant child items throughout my app... Just have to try to wrap my head around its usage :)
 
Niraj
buzztouch Evangelist
Profile
Posts: 2943
Reg: Jul 11, 2012
Cerritos
37,930
like
02/22/14 09:58 AM (10 years ago)
Have you consisted using the dataURL to bring in the childItems from an external data text file? I had 30,000 lines of JSON data in the main config file. The app ran fine. Yet I knew I was bordering on RAM catastrophe. I carved out the childItems for my biggest screen into its own JAON data file. Then that screen's dataURL pointed to that. I had uploaded the .txt file into the Files section of the App in the Control Panel. This resulted in two benefits: - No memory starvation for the app -- important for older devices - Independent updates for that Screen's data Alternatively, use a PHP-MySQL backend combined with loadScreenObject to dynamically generate the JSON childItem data for a particular screen. Either way, the BuzzTouch code will cache the "remote" data on the device for faster loading on the 2nd time henceforth. By the way, my main config file dropped from 30-thousand lines down to 3-thousand lines! -- Niraj
 
Niraj
buzztouch Evangelist
Profile
Posts: 2943
Reg: Jul 11, 2012
Cerritos
37,930
like
02/22/14 10:05 AM (10 years ago)
An informative post to read on loadScreenObject: http://www.buzztouch.com/forum/thread.php?tid=0AEFF1909A28E9AC27DD126 -- Niraj
 
Angry Ninja
Aspiring developer
Profile
Posts: 1045
Reg: Aug 25, 2013
Maine
17,150
like
02/22/14 07:44 PM (10 years ago)
I've actually not used a dataurl for json data yet... Only for calling php scripts to serve images and such so far. Basically looking for a way to automate my process, and I think json snippet keeper may be the answer... Here's my current format for a theme park app... It's the child menus that kill me. There's several main categories (food, shops, rides, etc)... Let's assume the top category we are looking at is park food. It basically goes like this: <Park Food> ..park section selection (5 menu items) ....restaurant selection (10-20 menu items per section, 75-100 locations total) EACH RESTAURANT ABOVE CONTAINS THE FOLLOWING CHILD ITEMS (x75-100 locations) ......overview (1 html page) ......menu (1 html page) ......photos of location. (20 photos, mosaic menu) ......photos of food. (20 photos, mosaic menu) ......videos of attraction (5 videos, YouTube playlist) ......locate this attraction (1 map, location map plugin) ......comments and reviews (customurl to php script) Now that's just one branch. Other branches, like rides, shops, maps, attractions, etc... About 15-20 branches total. I've just completed the food section by hand, and already at 514 screens, and about 4 months into it, lol. Hopefully I can get a grasp on json snippet keeper and it can save me some time. All the screens follow the exact same format, with only minor changes in the file names and nav bar titles.
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
02/22/14 08:26 PM (10 years ago)
If you're self hosted, I modified a script that can make things a *lot* easier… http://www.buzztouch.com/forum/thread.php?tid=A27A66998C9514DA91C7924&fid=06DB0BCB08E6666&sortColumn=FT.id&sortUpDown=&currentPage=2 Although Buzztouchmods is sort of offline at the moment, it'll return soon. In the meantime you can nab a copy from here: https://dl.dropboxusercontent.com/u/115208762/sjcon.zip Cheers! -- Smug
 
Niraj
buzztouch Evangelist
Profile
Posts: 2943
Reg: Jul 11, 2012
Cerritos
37,930
like
02/22/14 08:29 PM (10 years ago)
@AN -- You have just described more reasons to use a Database + PHP + loadScreenObject to take care of the repetition. Or have that Server-side generate text files in JSON format.
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
02/22/14 09:33 PM (10 years ago)
I was thinking the same thing, Niraj… Anything over 10 records really, can see advantages to having a text or database driven childItem file. a childItem file full of 'loadScreenObject' items rather than loadScreenWithId or loadScreenWithNickname gives you far greater 'dynamic' capability. Rather than creating 100 screens, you're creating 'screens on demand', without worrying about having to create 1 screen per item in the control panel, or whether or not the menus are connected correctly. You do it all 'on the fly' with fast accurate results. It all depends on your grasp, really. Json is an odd style, and not everyone connects the dots immediately. But it's all the same thing. Objects, and more objects. Once you understand the concept of an object, it's really just repetitive stuff within repetitive stuff. Most of your json would look similar to this: { "itemId":"1111", "itemType":"BT_screen_menuListSimple", "navBarTitleText":"My Simple Menu", "childItems":[ { "itemId":"menu_1", "itemType":"BT_menuItem", "titleText":"This is row 1", "loadScreenWithItemId":"1234" }, { "itemId":"menu_2", "itemType":"BT_menuItem", "titleText":"This is row two", "loadScreenWithItemId":"5678" } ] } But using a dataURL for your childItems for loadScreenObject would work like this: (your menu item 'dataURL' would be either to a text file with json, or a web based data driven response, such as php/mysql) {"childItems":[ { "itemId":"02816", "itemType":"SW_locationItem", "itemNickname":"02816", "iconName":"geckoinfo.png", "titleText":"Antonio B. Won Pat International Airport", "descriptionText":"Guam's Commercial Airport", "latitude":13.49241, "longitude":144.80502, "categoryText":"Airport", "subcategoryText":"Airport", "loadScreenObject": { "itemId": "02186", "itemType": "BT_screen_map", "itemNickname": "Airport", "navBarTitleText": "Antonio B Won Pat Airport", "singleLocationDefaultZoom": "15", "defaultMapType": "hybrid", "childItems": [ { "itemId": "83EABCB56DE7AEBCC3E63AC", "itemType": "BT_mapLocation", "latitude": "13.5", "longitude": "144.8", "title": "My Location", "subTitle": "My Location Subtitle", "pinColor": "red", "transitionType": "fade", "loadScreenWithItemId": "showDirections" }, { "itemId": "A5906684B33124AC6C6AB02", "itemType": "BT_mapLocation", "latitude": "13.52", "longitude": "144.82", "title": "My other location", "subTitle": "my other location subtitle", "pinColor": "green", "loadScreenWithItemId": "showDirections" } ] } }, { "itemId":"09374", "itemNickname":"09374", "itemType":"SW_locationItem", "iconName":"geckoinfo.png", "titleText":"Freedom Air - Tiyan", "descriptionText":"Local Airline between Guam, Saipan, and Rota.", "latitude":13.47813, "longitude":144.79597, "categoryText":"Airport", "subcategoryText":"Airline", "loadScreenObject": { "itemId": "09374", "itemType": "BT_screen_map", "itemNickname": "Airport", "navBarTitleText": "Freedom Air - Tiyan", "singleLocationDefaultZoom": "15", "defaultMapType": "hybrid", "childItems": [ { "itemId": "83EABCB56DE7AEBCC3E63AC", "itemType": "BT_mapLocation", "latitude": "13.5", "longitude": "144.8", "title": "My Location", "subTitle": "My Location Subtitle", "pinColor": "red", "transitionType": "fade", "loadScreenWithItemId": "showDirections" }, { "itemId": "A5906684B33124AC6C6AB02", "itemType": "BT_mapLocation", "latitude": "13.52", "longitude": "144.82", "title": "My other location", "subTitle": "my other location subtitle", "pinColor": "green", "loadScreenWithItemId": "showDirections" } ] } } ]} It's all the same thing, just delivered a little differently. all a 'loadScreenObject' really is, is a screen description in json created by the values of your database rather than the control panel. As such, you can dynamically create 1 or 1 thousand screen from a simple PHP Script, or a text workflow that can easily add/replace values when you need to. I have a little loadScreenObject 'kit' that you can play with located here: https://dl.dropboxusercontent.com/u/115208762/loadScreenObject.zip And if you're going to work with stuff like that, I'd suggest getting a text based http client so you can study your responses looking at 'Raw Data'. I use this one: http://ditchnet.org/httpclient/ it works great, and it is competitively priced. Although I'm certain similar items exist for the PC, I don't do my development in Windows, so I'm not sure of any candidates. But they're great for looking at your PHP output while developing your custom scripts. Cheers! -- Smug
 
Niraj
buzztouch Evangelist
Profile
Posts: 2943
Reg: Jul 11, 2012
Cerritos
37,930
like
02/22/14 10:01 PM (10 years ago)
Hahaha -- I love Smug even more with that quip of "... I don't do my development in Windows ...". He rocks my world :-) -- Niraj
 

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.