Page 1 of 1

dir argument for {content_image} not parsed before _display_image_block called

Posted: Mon Oct 11, 2010 11:57 pm
by codegrunt
Howdy.  While trying to set up some templates to load images from a directory based on the current site section (as pulled from the menu manager via a custom tag), I have run into an issue with the admin template parser.

The problem is that at page edit time, the image list for {content_image} is loaded via the _display_image_block() method in "./lib/classes/contenttypes/Content.inc.php".  I am not sure where this is called from (I am new to this codebase) but the problem is that the "dir" argument is not parsed as other Smarty template vars are. 

This means that the following attempt to pass a dynamically generated directory name fails:

Code: Select all

{content_image block="image1" label="left image" dir="images/static/$mySectionAlias"}
The problem is that the _display_image_block() method is getting passed the literal string "images/static/$mySectionAlias" instead of the parsed value.  Anyone know whether what I am trying to do is impossible or is there a way to pass a dynamic value for the dir argument of {content_image}?  My goal is try to limit what images are presented to something specific to the site section without having to create a bunch of extra templates with hard-coded paths.

Any help appreciated.

Cheers

Re: dir argument for {content_image} not parsed before _display_image_block called

Posted: Tue Oct 12, 2010 12:08 am
by calguy1000
The admin does not use smarty to parse the page template to find content blocks.
it's done manually with grep.

The smarty stuff works on the frontend, not in the admin.

Re: dir argument for {content_image} not parsed before _display_image_block called

Posted: Tue Oct 12, 2010 12:17 am
by codegrunt
Ok, good to know that you can only pass static values to placeholders that control anything in the editor view. 

Do I need to open a bug report to get that into the documentation? 

Cheers

Re: dir argument for {content_image} not parsed before _display_image_block called

Posted: Wed Oct 13, 2010 5:54 pm
by NaN
If you want dynamic values you can try the AdvancedContent module to display the content blocks. It processes smarty stuff also in backend. Read the module documentation for more info.