Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 10    Views: 117

Niraj
buzztouch Evangelist
Profile
Posts: 2943
Reg: Jul 11, 2012
Cerritos
37,930
03/16/14 08:55 PM (10 years ago)

Control Panel needs Grandchildren capability

How do I make a Control Panel that handles Grandchildren? In a normal Control Panel for a Plugin Screen, one can insert Children by adding new rows to a Menu table very easily. Take it one step further, I want to add a series of rows that have a single row as a Parent. For example, on the screen, I want to show two groups of information about an auto giant, General Motors. The General Motors screen will have: 1. Chevy Cars 1.a Spark 1.b Sonic 1.c Cruze 1.d Malibu 1.e Impala 2. Caddy Cars 2.a CTS 2.b ELR 2.c SRX 2.d ATS 2.e Escalade and so on ... I want all that information on a single screen, grouped by Chevy and grouped by Cadillac. In a sense, Chevy is a category or a section and Cadillac is another category / section. I have the iOS plugin code working just fine. Now I have turned my nose towards making the Control Panel for the plugin. I have peeked at the JSON on the Checklist plugin's description page. It does not use grandchildren for it's categories. Instead, it uses "itemType" as a discriminator between Category, Checklist and Checklist Item. My plugin is already coded. I don't want to change it just to accommodate the Control Panel. Any tips would be helpful. Thank you! -- Niraj
 
Niraj
buzztouch Evangelist
Profile
Posts: 2943
Reg: Jul 11, 2012
Cerritos
37,930
like
03/16/14 08:58 PM (10 years ago)
Here is the example JSON for my plugin: Stick it into http://jsonLint.com for better readability. { "itemId": "GeneralMotors", "itemType": "NS_CustomPlugin", "itemNickname": "General Motors", "navBarTitleText": "General Motors", "childItems": [ { "itemId": "ChevyTable", "itemType": "NS_CustomPluginItem", "loadScreenWithItemId": "123456", "titleText": "Chevy Cars", "childItems": [ { "itemId": "Chevy1", "itemType": "BT_menuItem", "loadScreenWithItemId": "ChevySpark", "titleText": "Spark", "descriptionText": "", "iconName": "ChevySpark.png", "rowCellStyle": "titleOnly" }, { "itemId": "Chevy2", "itemType": "BT_menuItem", "loadScreenWithItemId": "ChevySonic", "titleText": "Sonic", "descriptionText": "", "iconName": "ChevySonic.png", "rowCellStyle": "titleOnly" }, { "itemId": "Chevy3", "itemType": "BT_menuItem", "loadScreenWithItemId": "ChevyCruze", "titleText": "Cruze", "descriptionText": "", "iconName": "ChevyCruze.png", "rowCellStyle": "titleOnly" }, { "itemId": "Chevy4", "itemType": "BT_menuItem", "loadScreenWithItemId": "ChevyMalibu", "titleText": "Malibu", "descriptionText": "", "iconName": "ChevyMalibu.png", "rowCellStyle": "titleOnly" }, { "itemId": "Chevy5", "itemType": "BT_menuItem", "loadScreenWithItemId": "ChevyImpala", "titleText": "Impala", "descriptionText": "", "iconName": "ChevyImpala.png", "rowCellStyle": "titleOnly" } ] }, { "itemId": "CadillacTable", "itemType": "NS_CustomPluginItem", "loadScreenWithItemId": "654321", "titleText": "Cadillac Cars", "childItems": [ { "itemId": "Caddy1", "itemType": "BT_menuItem", "loadScreenWithItemId": "CaddyCTS", "titleText": "CTS", "descriptionText": "", "iconName": "CaddyCTS.png", "rowCellStyle": "titleOnly" }, { "itemId": "Caddy2", "itemType": "BT_menuItem", "loadScreenWithItemId": "CaddyELR", "titleText": "ELR", "descriptionText": "", "iconName": "CaddyELR.png", "rowCellStyle": "titleOnly" }, { "itemId": "Caddy3", "itemType": "BT_menuItem", "loadScreenWithItemId": "CaddySRX", "titleText": "SRX", "descriptionText": "", "iconName": "CaddySRX.png", "rowCellStyle": "titleOnly" }, { "itemId": "Caddy4", "itemType": "BT_menuItem", "loadScreenWithItemId": "CaddyATS", "titleText": "ATS", "descriptionText": "", "iconName": "CaddyATS.png", "rowCellStyle": "titleOnly" }, { "itemId": "Caddy5", "itemType": "BT_menuItem", "loadScreenWithItemId": "CaddyEscalade", "titleText": "Escalade", "descriptionText": "", "iconName": "CaddyEscalade.png", "rowCellStyle": "titleOnly" } ] } ] }
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
03/16/14 09:48 PM (10 years ago)
I *think* you'll be able to pull that off *if* you use an external URL… I've been wrestling with the same concept for a plugin that's under construction…a 'location detail' page that will include icons, text, a gallery and a map. With so much different data, there is NO way I'll be able to use a single 'childItem' concept to get it to work… So I was planning on several different 'outside' json files to mitigate it, either the dev will include it in the bundle, or online, or php driven. You might also want to take a look at Chris1's checklist plugin… I don't have it, but I saw some JSON from the config… it seems he's using json childItems for both checklist titles and the underlying data, and parses it out within the plugin (somehow… again, haven't looked under the hood). Cheers! -- Smug
 
nadthevlad
Code is Art
Profile
Posts: 1025
Reg: Jun 07, 2012
Denver
21,850
like
03/17/14 12:15 AM (10 years ago)
I think the first two answers here look very promising. They have the html and javascript. This is for forming the json on the client side (html/javascript). https://stackoverflow.com/questions/1184624/convert-form-data-to-js-object-with-jquery
 
nadthevlad
Code is Art
Profile
Posts: 1025
Reg: Jun 07, 2012
Denver
21,850
like
03/17/14 12:26 AM (10 years ago)
This looks promising too. http://www.alpacajs.org http://www.alpacajs.org/web/resources.html Edit: This one is a little rough around the edges.
 
nadthevlad
Code is Art
Profile
Posts: 1025
Reg: Jun 07, 2012
Denver
21,850
like
03/17/14 12:39 AM (10 years ago)
And a good tutorial for using javascript and json https://developer.mozilla.org/en-US/docs/JSON#toJSON%28%29_method
 
Niraj
buzztouch Evangelist
Profile
Posts: 2943
Reg: Jul 11, 2012
Cerritos
37,930
like
03/17/14 07:01 AM (10 years ago)
@Smug -- the external URL approach for pulling in a JSON data file works very nicely. That is how I have built the custom plugin without a Control Panel. Yet that approach requires one to hand-create the JSON -- which won't work for many of the BT Users. @Nick -- thanks for all that research! I had not even thought of looking for Form-to-JSON solutions. I guess my head was hoping for a built-in solution within the BT Framework. I will have to investigate how to get that data in-and-out of the database. I will take another look at the Checklist plugin -- I did not want to change my data model ... Yet, I also want to stay within the BT Framework. I am accepting that "change is good" :-) -- Niraj
 
Niraj
buzztouch Evangelist
Profile
Posts: 2943
Reg: Jul 11, 2012
Cerritos
37,930
like
03/17/14 07:04 AM (10 years ago)
@Smug -- my custom plugin already does most of what you desire. The Map component should be easy to add into it.
 
ATRAIN53
Code is Art
Profile
Posts: 1755
Reg: Nov 17, 2011
Chicago
26,450
like
03/17/14 08:06 AM (10 years ago)
FWIW... When 3.0 SH came out and we had all the child item issues- and then the fact I still have a SH install that can only run PHP 5.4 and child items do not work with BT SH and PHP 5.4.... I used a plist to 'build' a table type menu dynamically. Plists are really just xml files and you can read a plist locally or remotely and feed it into an array. No PHP, no SB JSON Parser required. I won't get into the PLIST vs JSON debate- but PLISTS are native to iOS and you can build very complex structures with arrays of dictionaries using plists.
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
03/17/14 08:33 AM (10 years ago)
Niraj - definitely take a look at my checklist plugin. When I originally created it, I couldn't think of a way to possibly get around not having grandchildren in my JSON. But, when the automated plugin market opened up I decided I needed to find a way so that I could get the plugin released. Turned out it wasn't too hard at all - everything is a normal childItem now, and I just do a lot of cross-referencing using custom properties to make it work. Think of it this way. My original concept was like this: Level 0: Screen childItem level 1: checklist childItem level 2: category childItem level 3: item New way: Level 0: Screen childItem level 1: checklist childItem level 1: category containing reference to itemId of checklist item childItem level 1: item containing reference to itemId of category Now, the app parses all the childItems, and builds arrays for checklist objects and category objects based on the cross-referenced information.
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
03/18/14 04:49 AM (10 years ago)
Ah. Clever. :) Cheers! -- Smug
 

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.