Testing to see if a content block exists / contains content

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
megwoo
Forum Members
Forum Members
Posts: 11
Joined: Thu Nov 10, 2005 1:08 am

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

Post 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!
ChrisC

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

Post 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...
fr3nch13

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

Post 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.
Ted
Power Poster
Power Poster
Posts: 3329
Joined: Fri Jun 11, 2004 6:58 pm
Location: Fairless Hills, Pa USA

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

Post by Ted »

I'll look into this evening...
User avatar
petert
Power Poster
Power Poster
Posts: 282
Joined: Wed Feb 09, 2005 9:30 pm
Location: behind my desk

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

Post 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)
Mambo sucks, that's why I am here.
Now they call it Joomla, but it still sucks!

CMSMS rules!
Ted
Power Poster
Power Poster
Posts: 3329
Joined: Fri Jun 11, 2004 6:58 pm
Location: Fairless Hills, Pa USA

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

Post 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.  :)
Post Reply

Return to “CMSMS Core”