Discussion Forums  >  Config Data, JSON, App Refresh

Replies: 5    Views: 285

HerrNathan
Aspiring developer
Profile
Posts: 73
Reg: Oct 11, 2011
Stirling
5,830
11/05/12 05:01 AM (13 years ago)

Dynamic List Items using JSON and PHP

Hi All, Hoping somebody can shed some light on this problem! I'm trying to create a dynamic list that will be populated from a PHP database. I want a list of venues that once clicked will open a new list of times (which clicked will take you to an HTML doc). Initially my idea was to use the RSS plugin, but it seems that its not available yet for 2.0. Currently I've created a custom menu list and pointed it to a page that provides the items via JSON {"childItems":[ {"itemId":"0001", "itemType":"BT_menuItem", "loadScreenWithItemId":"A892174CA5D4BEA2EFCB823", "dataURL":"http://mydomain.com/new.php?id=1", "titleText":"Item One"}, {"itemId":"0002", "itemType":"BT_menuItem", "loadScreenWithItemId":"A892174CA5D4BEA2EFCB823", "dataURL":"http://mydomain.com/new.php?id=2", "titleText":"Item Two"} ]} This creates the menu list I need but does not pass the data to the custom url page. Any ideas?
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
11/05/12 10:03 AM (13 years ago)
I don't think you can use dataURL in the childitem. You need to have each child item point to a different screen (through the loadScreenWithItemId:), then those screens can use the dataURL property to do what you want. For example: {"childItems":[ {"itemId":"0001", "itemType":"BT_menuItem", "loadScreenWithItemId":"screen1", "titleText":"Item One"}, {"itemId":"0002", "itemType":"BT_menuItem", "loadScreenWithItemId":"screen2", "titleText":"Item Two"} ]} {"itemId":"screen1","itemType":"BT_screen_customURL","itemNickname":"screen1","dataURL":"http://mydomain.com/new.php?id=1","navBarTitleText":"screen 1"}, {"itemId":"screen2","itemType":"BT_screen_customURL","itemNickname":"screen2","dataURL":"http://mydomain.com/new.php?id=2","navBarTitleText":"screen 2"} Chris https://www.churchphoneapps.com
 
HerrNathan
Aspiring developer
Profile
Posts: 73
Reg: Oct 11, 2011
Stirling
5,830
like
11/05/12 12:52 PM (13 years ago)
Hi Chris, Thanks for the reply! I was worried that was the case :( Unfortunately, the venues and times will change on a daily basis and there will be too many possible permutations, making it impractical to create a different screen for each of them. Had given some thought to just creating them as a webpage but have had earlier problems getting Apps approved due to the fact they were considered too similar to web content. Had also considered attempting to write a RSS plugin for 2.0 but reckon that's too steep a learning curve in the time I have to finish this :( Guess I need to have a re-think unless anybody else can think of another solution?
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
11/05/12 01:14 PM (13 years ago)
if you're getting the childitems from php, why not use php to create the entire config.txt? That way you can create the screens dynamically. Here's how you could do this: <start file> <copy most of config.txt here> <?php echo [code for menuscreen with child items] echo [code for new screen1]; echo [code for new screen2]; ?> <finish the rest of config.txt here> <end file> Of course, you'd be forgoing making changes to the app via control panel. You could probably accomplish it using just the dataurl for the childitems, although that might take some manipulation to close off the current screen, create the new screens, and start a screen that would be finished by the config.txt file (if that makes sense)
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
11/05/12 03:03 PM (13 years ago)
 
HerrNathan
Aspiring developer
Profile
Posts: 73
Reg: Oct 11, 2011
Stirling
5,830
like
11/05/12 03:43 PM (13 years ago)
Chris, Thanks for the suggestions. The link you've posted looks very promising! Should give me a good place to start! Really appreciate your help!
 

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.