Php if语句检查某些未定义对象的值

I am using smarty template system and am trying to do this for an if statement

{if isset($left_column_size) && !empty($left_column_size) && $category->name ne "Health"}

This works but if no category object is set for the given page I get php notices:
Undefined index: category
Trying to get property of non-object

What I really want is something as follows

{if isset($left_column_size) && !empty($left_column_size) {if isset($category)}&& $category->name ne "Health"{/if}}

If I try this I get the error Smarty Compiler: Syntax error in template code too many shorthand attributes. Does anyone know what the right thing to do here to get rid of those php error notices is? Thanks

It looks like you were on the right track. Try something along these lines

if(!empty($left_column_size) &&
  ((!empty($category) && $category->name ne "Health") 
    || empty($category))

I ended up solving this by doing:

{if isset($left_column_size) && !empty($left_column_size) && 
( empty($category) || (!empty($category) &&$category->name ne "Health Topics"))}