{content_image dir=$variable} - Possible?

The place to talk about things that are related to CMS Made simple, but don't fit anywhere else.
Post Reply
henson
Forum Members
Forum Members
Posts: 20
Joined: Mon Sep 17, 2007 11:17 pm

{content_image dir=$variable} - Possible?

Post 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.
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1973
Joined: Mon Jan 29, 2007 4:47 pm

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

Post 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...
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

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

Post 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.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
chandra

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

Post by chandra »

@henson: Maybe an additional module could be helpful for your idea / project

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

Return to “The Lounge”