Error with PropCategory being null in catalog.aspx

Developer
Jul 10, 2009 at 1:13 AM

Hi all -

I'm new at Umbraco. I'm considering C4U for a small-to-medium etailer.

In the example site, I'm browsing manually to the Catalog page. This apparently causes PropCategory to be null. However, in the catalog.aspx control, that property is only checked against String.Empty instead of using String.IsNullOrEmpty, as I might expect. This causes the page to error out with an InvalidOperationException "There is no row at index 0" since the first table in the dataset returned is empty. Is this by design? Why not use String.IsNullOrEmpty to guard against this? How does the assumption that PropCategory is always non-null get established?

Thanks,

-rory

Coordinator
Jul 10, 2009 at 8:06 PM

Rory -

Please feel free to submit a patch - you'll likely find many areas for improvement in this (and most other projects).

The catalog UC is intended to display a single, specific category - therefore the category must be non-null.  If you're thinking of a catalog listing all categories, this is a different feature.

-Paul

Developer
Jul 12, 2009 at 8:12 PM

Thanks Paul,

I'd happily submit a patch when I feel that I'm doing less harm than good.

I'm trying to understand the significance of the "[@c]" in the PropCategory parameter of the CategoryList macro. I just can't seem to track it down - is it a metaparameter, an xpath for an xml attribute...?

-r

Developer
Jul 12, 2009 at 8:55 PM

NM. I just found the umbraco macro parameters syntax documentation after much searching.

-r

Coordinator
Jul 13, 2009 at 3:45 PM

Glad you figured it out! 

For the benefit others who run into this thread - the [@c] syntax is Umbraco shorthand for referencing a Request value.  So, in this case, we're getting the value of the 'c' key from the Query String.  It's not obvious as we use URL rewriting to create friendly Url's - with the rewriting the Url looks like:

http://<your domain>/catalog.aspx?c=<category name>

-Paul