This project is read-only.

Error with PropCategory being null in catalog.aspx

Jul 10, 2009 at 2: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?



Jul 10, 2009 at 9: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.


Jul 12, 2009 at 9: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...?


Jul 12, 2009 at 9:55 PM

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


Jul 13, 2009 at 4: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>