Skip to content

Instantly share code, notes, and snippets.

@opengeek
Created September 18, 2012 17:08
Show Gist options
  • Save opengeek/3744346 to your computer and use it in GitHub Desktop.
Save opengeek/3744346 to your computer and use it in GitHub Desktop.
Example of optimizing conditional filters using a Chunk wrapper
[[[[*page-image:notempty=`$wrapImgThumb? &src=`*page-image` &alt=`[[*pagetitle]]` &thumbOpts=`w=480&h=320``]]]]
[[*page-image:notempty=`<img src="[[*page-image:phpthumbof=`w=480h=320`]]" alt="[[*pagetitle]]" />`]]
<img src="[[[[+src]]:phpthumbof=`[[+thumbOpts]]`]]" alt="[[+alt]]" />
@Hannes-III
Copy link

I do not understand the difference why the prperty src is just filled with *page-image and the alt property needs its resource field referenced by [[*pagetitle]].
If both cases work, then it should be possible to write it both ways? This:

[[[[*page-image:notempty=`$wrapImgThumb? &src=`[[*page-image]]` &alt=`[[*pagetitle]]` ... `]]]]

is the same as that:

[[[[*page-image:notempty=`$wrapImgThumb? &src=`*page-image` &alt=`*pagetitle` ... `]]]]

Is that right?

The rason why this will work is, that the resource tags can be accessed from all chunks. No matter how deep they are nested.

But it would not work if I am already in a chunk and I try to call another chunk using placeholders like that:

[[[[+pImage:notempty=`$wrapImgThumb? &src=`+pImage` &alt=`+pTitle` ... `]]]]

This would not work, would it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment