Category ID not being returned So, in my template I get what I'm calling parentCategory, and I can output what I need:

{% set parentCategory = craft.categories.slug(craft.request.getSegment(2)) %}
{# parentCategory.title and parentCategory.slug output fine #}


But shortly after, I'm wanting to get all the descendants of parentCategory, like so:

{% set cats = craft.categories.descendantOf(parentCategory.id).find() %}
{# outputs all categories, whether descendants or not #}


It seems parentCategory.id is empty:

{{ parentCategory.id }}
{# outputs nothing #}


Any ideas where I'm going wrong here? Why is no ID being returned while title, slug and my custom fields are working fine?

Here's line 1 and 2 from my template:

{% if craft.request.getSegment(3) %}
    {% set parentCategory = craft.categories.slug(craft.request.getSegment(2)) %}


If I change line 2 to:
{% set parentCategory = craft.categories.slug(craft.request.getSegment(2)).first() %}

I get the following error:

Craft\CategoryModel and its behaviors do not have a method or closure named "first".


Yet, I can repeat line 2 later in the template and include .first() and not get the error. What go on?
The craft.categories tag returns an ElementCriteriaModel, so parentCategory.title really shouldn't work. Try changing the first line of code to:

{% set parentCategory = craft.categories.slug(craft.request.getSegment(2)).first() %}