Page 2 of 2

Re: Testing to see if a content block exists / contains content

Posted: Fri Jan 27, 2006 1:27 am
by megwoo
I was wondering if anyone figured out an alternate way of testing for content...

The {capture name='contentoutput'} worked for me on an older CMS MC version, but as soon as we upgraded it broke--and no changes were made to content in the database.

Thanks!

Re: Testing to see if a content block exists / contains content

Posted: Tue Jan 31, 2006 3:34 pm
by ChrisC
There seems to be a really odd interaction between caching and a {content} block inside a {capture} block. 

Say that {content block='Header Image'} displays 'get_involved.gif'.

The capture block below behaves quite oddly:

{capture name='contentoutput'}{content block='Header Image'}{/capture}

If I follow it with:

Len: {$smarty.capture.contentoutput|count_characters:true}{$smarty.capture.contentoutput|escape:"url"}[{content block='Header Image'}]

I see:

Len:105 %7Bnocache%3A80a46186b6839c425d51aa8f6587c6d7%236%7Dget_involved.jpg%7B%2Fnocache%3A80a46186b6839c425d51aa8f6587c6d7%236%7D[get_involved.jpg]

So, the content block inside the {capture} tag evaluates to something that's 105 characters long.  (And that happens whether or not the content block has content.)  However, the last call to a {content} tag -- the one at the end in square brackets there --- shows the correct information.

None of this happens on my localhost server which isn't caching, but it does happen on the staging server.  Both are running 11.2.

If I unescape that value, I get:
{nocache:f4472ff0bc0531eee694fa8caf523d0d#5}{/nocache:f4472ff0bc0531eee694fa8caf523d0d#5}

So it looks like some form of nocache tags doesn't get evaluated if inside a {capture} pair.  And that's about where my ability to poke around reaches a dead end...  Maybe after some sleep I'll have a moment of cleverness...

Re: Testing to see if a content block exists / contains content

Posted: Tue Feb 07, 2006 7:58 pm
by fr3nch13
has anyone found a solution for this? i tried all of the above ideas and the content still shows up even if the content is empty.

Re: Testing to see if a content block exists / contains content

Posted: Tue Feb 07, 2006 11:14 pm
by Ted
I'll look into this evening...

Re: Testing to see if a content block exists / contains content

Posted: Sun Mar 12, 2006 11:11 am
by petert
wishy wrote: I'll look into this evening...
Did you ? :)
I am stumbling here with exactly the same problem. The capture seems empty but is filled with the nocache:  message.
I am using 0.12 (fiji)

Re: Testing to see if a content block exists / contains content

Posted: Mon Mar 27, 2006 5:43 pm
by Ted
Ok, so a patch that came to me from djnz right before I released 0.12.1 has fixed this issue.  It goes something like this:

Code: Select all

{content block='headercontent' assign='smartyvar'}
{if $smartyvar ne ""}<div id="somediv">{$smartyvar}</div>{/if}
Hope that finally clears this issue up once and for all.  :)