Page 1 of 1

{content_image dir=$variable} - Possible?

Posted: Sat Sep 03, 2016 10:36 pm
by henson
Hi All,

I am running CMSMS 2.1.2, CGSimpleSmarty, CGContentUtils and CGExtensions installed.

I have a number of products that are broken down into sub sections, sometimes 4 levels deep. I have created page structure and URLs that replicate the categories etc...

(eg. example.com/products/rootcategory/category/subcategory/productname/)

I have uploaded the images for these to example.com/uploads/images/products/rootcategory/category/subcategory/productname/

Each product has multiple images.

I am trying to use {content_image} tag in the template to allow the CMS user to select the page image they want from the directory of that specific item, rather than having a massive long list of file names to pick from.

If I hard code in the dir parameter within the content_image tag, it works perfectly, however if I obtain the directory structure via smarty

Code: Select all

{cms_selflink href=$page_alias assign='dir'}
{$dir|replace:'http://example.com':'images' assign='dir'}

printing {$dir} to the page outputs the exact same string as in my hard coded test, but when used like this

Code: Select all


{content_image block='page_thumb' dir="{$dir}"}

or 

{content_image block='page_thumb' dir=$dir}

I get the error "Error: Invalid path specified for {content_image} tag."

and no matter what I have tried, I run into a brick wall.


Any help/ideas to try would be very gratefully received!

Thanks in advance

Marc

==============

FYI

What I am trying to achieve is to assign the chosen image on the page to a content block that can be fetched by it's parent page (via CGSimpleSmarty) to show a list of all of the sub page thumbs.

I've actually got this functionality working when the dir param is hard coded, but obviously this isnt going to be possible for every page.

Re: {content_image dir=$variable} - Possible?

Posted: Mon Sep 05, 2016 5:26 pm
by Jo Morg
Please search the forum about scopes, and check this article: http://www.cmscanbesimple.org/blog/smar ... e-examples.
Apologies, the correct answer is bellow, of course...

Re: {content_image dir=$variable} - Possible?

Posted: Mon Sep 05, 2016 6:28 pm
by calguy1000
I am trying to use {content_image} tag in the template to allow the CMS user to select the page image they want from the directory of that specific item, rather than having a massive long list of file names to pick from.

If I hard code in the dir parameter within the content_image tag, it works perfectly, however if I obtain the directory structure via smarty
Unfortunately, this won't work.

When editing a content page we merely temporarily compile the smarty template and use callbacks to build a list of the various {content} blocks. You cannot use smarty logic or variables to control the presentation of the edit content page.

Re: {content_image dir=$variable} - Possible?

Posted: Wed Sep 07, 2016 3:42 pm
by chandra
@henson: Maybe an additional module could be helpful for your idea / project

http://dev.cmsmadesimple.org/projects/ecb2