Avoid notice of variable's not being set within dev mode With dev mode on, I'm getting a warning there is no entry.title, which I know about already because that's what I'm testing for:

{% if entry.title | length == 0 %}
    {% set entry = craft.entries.section('sectionname').slug(craft.request.segment(2)).first() %}
{% endif %}


Is there a way to test for a variable without dev mode triggering this notice?
I've had luck using "is defined" before using other logic operators.

This should do it:

{% if entry.title is defined and entry.title | length == 0 %}
    {% set entry = craft.entries.section('sectionname').slug(craft.request.segment(2)).first() %}
{% endif %}