Discussion Forums  >  BT.com Website, Account Questions

Replies: 12    Views: 173

GraciousWolf_PE
Aspiring developer
Profile
Posts: 372
Reg: Feb 15, 2012
Montreal
10,720
08/24/13 08:52 AM (7 years ago)

Control Panel - Alphabetical Order?

Hey everyone!

I just had a quick question regarding the BT Control Panel (not self-hosted). As in my previous topic post, I just released a directory app that I plan on updating regularly.

I currently have everything in alphabetical order according to first name; however, it can be a real hassle adding 10 names at a time and having to arrange all the order numbers.

Is there any automatically way that the control panel could simply re-arrange the list in alphabetical order for me and save me half the trouble? :) Any other alternatives?

Thank you!

-Nicholas
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
08/24/13 04:14 PM (7 years ago)
What you may want to do is create a child item file that will be either embedded in the app, or available via URL.

This way you can alter your list fairly quick and easily without the control panel blocking certain concepts.

https://www.buzztouch.com/docs/v1.5/childItems.php

Cheers!

-- Smug
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
08/24/13 07:02 PM (7 years ago)
Oh. Just thought of something as well. Might be a challenge to implement depending on your skill level.

It would require the modification of code in your menu that you want 'sorted'.

In your menu class file, in the 'parseScreenData' method, you'll need to add a value in your menu items called "setSortableColumnValue" and assign the itemNickname to it:

[thisMenuItem setSortableColumnValue:[tmpJsonValues objectForKey:@"itemNickname"]];

Then, after the menu items have been 'read in' you sort them using NSSortDescriptor:

NSSortDescriptor *smugSortDescriptor = [[[NSSortDescriptor alloc] initWithKey:@"sortableColumnValue" ascending:YES selector:@selector(localizedStandardCompare:)] autorelease];
NSArray *sortDescriptors = [NSArray arrayWithObject:smugSortDescriptor];
[self.menuItems sortUsingDescriptors:sortDescriptors];

It really won't matter what order you 'enter' the data into the control panel; This will sort all the menu choices by itemNickname within the app prior to display.

Also keep in mind that a 'plugin' could also be considered a 'master template' sort of... If you make a modification to a plugin, then all 'screens' that use the plugin will be subject to the modification. So basically, if you make this menu sort, ALL screens using this menu will sort.

Cheers!

-- Smug
 
GraciousWolf_PE
Aspiring developer
Profile
Posts: 372
Reg: Feb 15, 2012
Montreal
10,720
like
08/24/13 08:22 PM (7 years ago)
Hey Smug,

Thanks for putting forth these options!

I'm actually interested in looking into option #2 and modifying the code (I understand the basic principle behind child items in option #1, but can't seem to wrap my mind around implementation).

The menu type I'm using is "Menu Simple". I have these menus for different countries as well as a compendium from A-Z. The items are all PDF files.

I also have a couple of other tabs created using the "Menu Simple" plugin and I understand that modifying this code will also set the items found within these menus in alphabetical order as well. I'm not too concerned about this and it would actually work just fine.

In this case, what's the exact code I would have to put in? In other words, I can see the basic code you mentioned in the previous post, but what would I have to replace to make this code work?

I don't want to sound lazy, but a copy & paste job sounds real appealing... allow me to soak up your knowledge! :P

Thanks again, Smug!

-Nicholas
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
08/24/13 10:05 PM (7 years ago)
See how this works for you.

Remember to comment out or save the original code... always leave a way to get back!

That said, this is intended to replace the 'parseScreenData' method within the BT_screen_menuListSimple.m file

http://pastebin.com/b3RHi1Ng

This link is good for about a week.

I haven't tested the code; caveat emptor!

Cheers!

-- Smug
 
GraciousWolf_PE
Aspiring developer
Profile
Posts: 372
Reg: Feb 15, 2012
Montreal
10,720
like
08/24/13 10:19 PM (7 years ago)
Hey Smug!

Thanks for that bit of code! Interestingly, I replaced the "parseScreenData" method within the BT_screen_menuListSimple.m file, there were no warnings or errors and the simulator ran with no problems.

That being said, the code did not affect the order (i.e. items were not alphabetized from A-Z).

Any thoughts?

Thanks again!!

-Nicholas
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
08/24/13 10:37 PM (7 years ago)
I'll dig a bit into it... I've got some things I need to clear up first, but I'll see what's up in a while.

It's probably in the sortdescriptors.

Cheers!

-- Smug
 
GraciousWolf_PE
Aspiring developer
Profile
Posts: 372
Reg: Feb 15, 2012
Montreal
10,720
like
08/24/13 10:39 PM (7 years ago)
No worries whatsoever, I really appreciate you taking the time to help me out with this. Would help big time with future updates and a directory that's ever growing!

Thanks again - highly, highly appreciated!

-Nicholas
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
08/25/13 04:18 AM (7 years ago)
Heh. Ok, I think I found my mistake.

Most of this comes from a custom plugin I created to sort locations by distance. Thus, I didn't actually 'use' a menu, so much as I stole code from a menu for my plugin. Thus, not everything is the same, lol!

In any event, what you'll want to do is this:

In the paste bin code (which you probably already have in your xcode project) change the code line 33 from:

[thisMenuItem setSortableColumnValue:[tmpMenuItem objectForKey:@"itemNickname"]];

and use this instead:

[thisMenuItem setSortableColumnValue:[tmpMenuItem objectForKey:@"titleText"]];

And you should be good.

The basic explanation is that the Simple Menu doesn't use 'itemNickname' for it's child items, it uses 'titleText'. I had you sorting an empty column, which explains the behavior (which is no behavior, lol!). Inserting 'titleText' will populate the sortableColumnValue with your menu item titles, which is your desire.

My bad. Oops, blah blah. Hope that fixes it up for you.

Cheers!

-- Smug
 
GraciousWolf_PE
Aspiring developer
Profile
Posts: 372
Reg: Feb 15, 2012
Montreal
10,720
like
08/25/13 10:14 AM (7 years ago)
Hey Smug,

That was a great find and I was on the edge of my seat when I thought that might do the trick!... but no dice. :P

Everything remains the same, no warnings or errors in the code, but the code itself isn't take my menu items and arranging them from A-Z...

Anything else up your sleeve? ;)

I'm actually heading out for a couple of days, so I won't be around my Mac to test things out, but I do appreciate your persistence on this manner and if you think of anything else, please feel free to let me know - I'll test it right away when I come back!

Thanks again, Smug, I appreciate it!

-Nicholas
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
08/25/13 03:12 PM (7 years ago)
Ok, I'm not really stupid, but I play one on Buzztouch.

I built a test environment with a Simple Menu, and found out it wasn't even hitting on the parseScreenData method. Silly me.

It's being populated via the load data method.

So, change that to this:

http://pastebin.com/Lw6B6nMc

It's been tried, tested, and proven. Sorry for all the confusion.

Cheers!

-- Smug
 
GraciousWolf_PE
Aspiring developer
Profile
Posts: 372
Reg: Feb 15, 2012
Montreal
10,720
like
08/27/13 03:46 PM (7 years ago)
Smug, you are a God.

Thank you so much, honestly, I couldn't have done it without you (like, at all)!

Made my life about 10x easier without having to constantly arrange an ever-growing directory list by alphabetical order - THANK YOU!

-Nicholas

:)
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
08/29/13 03:36 PM (7 years ago)
No problem, glad I could help. :)

In case anyone else needs this when pastebin expires:

https://dl.dropboxusercontent.com/u/115208762/simpMenuSortItems.txt

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.