Friday, July 24, 2009

Vertical Subcategory Listing in Entity XMLPackage

Last week, I was dead worried on how to do this.  The default in ASPDNSF is horizontal listing.  Although it's okay for my client to display that way, he wanted a vertical listing more.  I consulted the forum but to no avail.  Finally, I came up with a solution.  It's a very long one, and I must admit, it's not the best one either.  I'm hoping there's a shorter one, but for now, since I have a tight deadline, I'm okay with this solution.

Here's what I did.  I created a new XSLT function that accepts the parameters WebsiteID (This is multistore so WebsiteID is necessary), ParentCategoryID, and the NodeCount (although personally, I don't think this is necessary anymore).  This function does all the work.  I can't think of anything else that will only touch the XMLPackage so I went deeper.

In my XSLT function, I created an ArrayList of Items that will hold the nodes (or the subcategories) of my query.  I also created a temporary ArrayList that will hold each field of my subcategories.  This temporary one will be stored in ArrayList Items.

then made this code:
// sql query to store categor fields into temporary ArrayList
// then stores the temporary ArrayList to Items

double SubCategoryCount = Items.Count;

int ItemsPerColumn = (int) Math.Ceiling(SubCategoryCount / 3); // I only have three columns
int counter = 0;
StringBuilder str = new StringBuilder();

foreach (ArrayList al in Items) //traverses all subcategories in Items
        {
            if (counter < ItemsPerColumn)
            {
                str.Append("<tr>");
                // code for the first column

                if ((counter + ItemsPerColumn) < Items.Count) // checks if this index is not yet out of bounds
                {
                     ArrayList al2 = (ArrayList)Items[counter + ItemsPerColumn];
                     // code for the second column
                }

                if ((counter + ItemsPerColumn + ItemsPerColumn) < Items.Count) // checks if this index is not yet out of bounds
                {
                     ArrayList al3 = (ArrayList)Items[counter + ItemsPerColumn + ItemsPerColumn];
                     // code for the third column
                }

                str.Append("</tr>");
                counter++;
            }
            else
            {
                break;
            }
        }
This is a very long solution but works fine with me, so I'm sticking to this for now.


Thursday, July 23, 2009

VS IDE: Dots and Arrows

I'm a little bit ashamed to post this but somehow, I have a feeling I might be needing this in the future.

I was typing fast and while supposedly pressing a shortcut for something, I accidentally pressed the wrong keys that resulted to dots and arrows, dots replacing normal spaces and arrows replacing tabs.  I tried ignoring them since I don't know how I did that.  But I still found them annoying, and made me lost with my coding.

So I searched for this problem.  Luckily, I wasn't the only one who had this problem.  From a forum, even though the threader starter was OT, other forumers still answered him.

The solution:  Ctrl+Shift+8
If this won't work, try Ctrl+R+W

Simple, isn't it?  That's why I hate myself right now.  Haha!


Contact Details

I don't get it.  Why do some people constantly change their contact details, specifically mobile phone numbers?  From what I recall, I only changed my numbers three times since my very first cellphone.  My father only changed his mobile number once, when analog cellphones where faced out.  My sister, once when her phone was stolen the day our house was robbed.

You can say that because anonymous callers are bugging you.  They are indeed annoying, but is that reason enough to change number?  'Cause from what I see, the only ones who benefit from this are the network companies.  The more often you change your number, the more income they generate.

Sorry, I'm ranting again.  I'm just annoyed with constant changing of details, not only on mobile numbers.  My niece always changes her number and now, I have no way of reaching her.  Then there's also this annoying friend from my social network who constantly changes her public name.  I really believe she's doing this to increase her karma faster, but it's really annoying.  I just recognize it's her because she updates her status every now and then, and surprisingly, a lot in her circle are replying.  Imagine in your Facebook, someone floods your bulletin with eating this and that, then moments later, drinking this, then later again, "hayyy busog".  Wouldn't you become annoyed.

Here I go again, with the spaghetti-meatballs talk.  Better end this now before the topic goes somewhere else.

Just to point again, I don't like constant changing of contact details.