Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 6    Views: 118

nonaperak
Lost but trying
Profile
Posts: 15
Reg: Feb 04, 2011
location unknow...
3,250
12/27/12 12:53 AM (13 years ago)

Custom plugin on BT server, using v2.0

Hey all, sorry for my rudimentary question. Still rather new with BT. Here's what I need to achieve. I currently have a screen that uses the HTML Doc plugin. I need to create 12 more screens and the HTML Doc plugin works great with one exception. I'd like swipe functionality on the 12 new screens. Thanks to the excellent help in the forum, I was able to find coding to make swipe work. Awesome! The only problem now... I do NOT want swipe on the 1 old screen. Only on the new ones. So, I figured, if I could duplicate & re-create the HTML Doc plugin files, wouldn't that work? Here's the part where I'm unsure how to work out. I'm assuming this would be my steps. 1. Duplicate bt_screen_htmlDoc plugin folder and contents, re-name folder, .h, .m and all references to BT_screen_htmlDoc 2. Add to Xcode 3. Modify code to add swipe functionality 4. This is the part I'm unsure how to proceed. How do I add screens? Normally I'd do this in BT.com control panel. But because this plugin isn't on BT.com... Through more reading, I figure I simply need to write the JSON code to add screens. But how do I add this JSON code to my project? Am I going down the right path or am I trying to achieve the impossible? Thank you guys SO much!
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
12/27/12 04:02 AM (13 years ago)
Hold fire I'll be at a computer shortly. Use an if statement along lines If (screen == swipe){ Code for swipe else } You can have the if statement react to the one screen. Or if this will be a regular app feature we could edit the index.php file to include a swipe yes or no in the control panel. To control individual pages
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
12/27/12 05:07 AM (13 years ago)
I'm guessing you used my tutorial to swipe if so here is the full simple code, put this in the viewDidLoad method if(![[BT_strings getStyleValueForScreen:self.screenData:@"itemNickname":@""] isEqualToString:@"screenNickname"]) ///screenNickname is the screen you don't want swipe to be enabled { UISwipeGestureRecognizer *swipeLeft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(leftSwipe:)]; [swipeLeft setDirection:UISwipeGestureRecognizerDirectionLeft]; [self.view addGestureRecognizer:swipeLeft]; UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(rightSwipe:)]; [swipeRight setDirection:UISwipeGestureRecognizerDirectionRight]; [self.view addGestureRecognizer:swipeRight]; } These two methods outside of any other curly braces - (IBAction)leftSwipe:(id)sender { [self navLeftTap]; } - (IBAction)rightSwipe:(id)sender { [self navRightTap]; } Merry swipemas
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
12/27/12 05:23 AM (13 years ago)
for multiple screens without touch control try if([[BT_strings getStyleValueForScreen:self.screenData:@"itemNickname":@""] isEqualToString:@"screenNickname1"]|[[BT_strings getStyleValueForScreen:self.screenData:@"itemNickname":@""] isEqualToString:@"screenNickname2"]) // screenNickname1&2 being the screens you don't want to swipe. You could also swap the gesture statement for the nil to make the screens the only ones that swipe. { nil; } else { UISwipeGestureRecognizer *swipeLeft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(leftSwipe:)]; [swipeLeft setDirection:UISwipeGestureRecognizerDirectionLeft]; [self.view addGestureRecognizer:swipeLeft]; UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(rightSwipe:)]; [swipeRight setDirection:UISwipeGestureRecognizerDirectionRight]; [self.view addGestureRecognizer:swipeRight]; }
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
12/27/12 05:39 AM (13 years ago)
More advanced. You will need to amend the index.php file in the plugin. BY using ftp software navigate to your BT-server > files > plugins > bt_screen_htmlDoc then edit index.php. add this code in between <!-- ############### end search properties ################ --> <!-- ###################################################### --> and <!-- ###################################################### --> <!-- ############### advertisment properties ############## --> add this <!-- ##################################################### --> <!-- ############### swipe properties #################### --> <div class='cpExpandoBox colorLightBg'> <a href='#' onClick="fnExpandCollapse('box_swipe');return false;"><img src='<?php echo APP_URL;?>/images/arr_right.gif' alt='arrow' />Enable swipe?</a> <div id="box_swipe" style="display:none;"> <div style='padding-top:10px;'> <select name="json_swipe" id="json_swipe" style="width:250px;"> <option value="" <?php echo fnGetSelectedString("", fnGetJsonProperyValue("swipe", $jsonVars));?>>--select--</option> <option value="NO"<?php echo fnGetSelectedString("NO", fnGetJsonProperyValue("swipe", $jsonVars));?>>No, do not enable swipe</option> <option value="YES" <?php echo fnGetSelectedString("YES", fnGetJsonProperyValue("swipe", $jsonVars));?>>Yes, enable swipe</option> </select> </div> <div style='padding-top:5px;'> <input type='button' title="save" value="save" align='absmiddle' class="buttonSubmit" onClick="saveAdvancedProperty('saveResult_swipe');return false;"> <div id="saveResult_swipe" class="submit_working">&nbsp;</div> </div> </div> </div> <!-- ############### end swipe properties ############### --> <!-- ##################################################### --> That will now have a drop down similar to login required on your screen in the control panel. Now for the plugin code. add to the viewDidLoad method if([[BT_strings getStyleValueForScreen:self.screenData:@"swipe":@"NO"] isEqualToString:@"YES"]) { UISwipeGestureRecognizer *swipeLeft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(leftSwipe:)]; [swipeLeft setDirection:UISwipeGestureRecognizerDirectionLeft]; [self.view addGestureRecognizer:swipeLeft]; UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(rightSwipe:)]; [swipeRight setDirection:UISwipeGestureRecognizerDirectionRight]; [self.view addGestureRecognizer:swipeRight]; } } Add to code outside any other curly braces - (IBAction)leftSwipe:(id)sender { [self navLeftTap]; } - (IBAction)rightSwipe:(id)sender { [self navRightTap]; } You can do this on any or every screen in your control panel. Just make amendments to the .m file and the index.php for every plugin you want this to work with. I'll type this into a proper tutorial in the new year.
 
nonaperak
Lost but trying
Profile
Posts: 15
Reg: Feb 04, 2011
location unknow...
3,250
like
12/27/12 10:02 AM (13 years ago)
WOW Thank you so much Kittsy! I just got this so I will try that later today. Was just thinking this morning maybe I could use an if/else statement. An YES I did use your tut because it was the simplest to implement (that I could follow) Thanks once again. Will report later. The last example is excellent! I would have looked into the index.php since I am a PHP developer but sadly I'm not self-hosted. At least not yet, not for this app. Clipping this to Evernote :-D
 
ATRAIN53
Code is Art
Profile
Posts: 1755
Reg: Nov 17, 2011
Chicago
26,450
like
12/28/12 08:02 AM (13 years ago)
Welcome nonaperak. Check out this post too to help you understand how that index.php is associated with the plug-ins. http://www.buzztouch.com/forum/thread.php?tid=61A19811BADC9373C0AC264&command=isSearching&currentPage=1&topicTitle=JSON&createdBy=&repliedBy=&minViews=-1&maxViews=-1&minReplies=-1&maxReplies=-1&forumCategory= Thanks for the share/example. Merry swipemas indeed :)
 

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.