Quote from: rthrash at Mar 15, 2006, 04:52 PM
someone please fix the code as I’m not a coder
@EVAL return ([*description*] > '')? [*description*] : '{{DefaultMetaDesc}}';
I think it’s more better, both for the IF clause and for stability, to use:
@EVAL return (!empty([*description*]) ? [*description*] : '{{DefaultMetaDesc}}');
Well, I not sure if you really need the quotes for
’{{DefaultMetaDesc}}’
I have asked the same question for META description yesterday
here and I have not used @EVAL. When you write your Template Variable (TV), lets call it
MetaDescription and you can give a default value and you assign it to one or more templates. Then you place the code:
<meta name="description" content="[*MetaDescription*]" />
in your template file.
Now, when editing a document you will have the default value allready in the field assigned, if you want to change it go ahead, if not the default one is used.
This is what I have done to my template. Well, I am not the MODx expert because I’ve spent just some hours with it yet and I could be wrong. But it’s a bit easier.
Boby