Page 1 of 1
different dir to content_image
Posted: Wed Jul 10, 2013 1:40 am
by uloloi
How to assign different dir/folder in content_image tag ?
If I have different pages and sections
section1
page 1.1
page 1.2 cms_images take pictures from uploads/imgs/pics1
section 2
page2.1
page2.2 cms_images take pictures from uploads/imgs/pics2
I tried this:
Code: Select all
{if $cgsimple->get_root_alias() eq 'section1'}
{content_image block='images_1' label='images of theme' dir='images/pics' assign='img_slide'}
{/if}
But this block appears into all the pages
Re: different dir to content_image
Posted: Wed Jul 10, 2013 2:24 am
by calguy1000
try this:
Code: Select all
{cgsimple::get_root_alias('','root_alias')}
{$image_dir='images'}
{if $root_alias == 'section1'}
{$image_dir='images/dir1'}
{elseif $root_alis == 'section2'}
{$image_dir='images/dir2'}
{/if}
{content_image ... dir=$image_dir}
Re: different dir to content_image
Posted: Wed Jul 10, 2013 3:55 pm
by uloloi
Hi calguy, I tried your code and everything between the if condition and works fine, the problem is when apply it in the tag
{$img_dir = 'images/mydir'}
{content_image block='img_slideshome' label='Images in Home' dir=$img_dir}
content_image doesn't recognize the smarty $img_dir. When editing a content page in the section 'Images in Home' outputs this message: Error retreiving file list. But, It doesn't happen when I try this:
{content_image block='img_slideshome' label='Images in Home' dir='images/mydir'} (without smarty var)
So, I wrote an if ... else ... condition and I put this:
Code: Select all
{cgsimple::get_root_alias('','root_alias')}
{$image_dir='images'}
{if $root_alias == 'section1'}
{content_image block='img_slideshome' label='Images in Home Page' dir='images/mydir1'}
{elseif $root_alis == 'section2'}
{content_image block='img_slideshome' label='Images in Home Page' dir='images/mydir2'}
{/if}
But I can't use the same block name. Am I wrong in something? The smarty var really works fine into the content_image tag? Thanks for the help.
Re: different dir to content_image
Posted: Wed Sep 11, 2013 4:45 pm
by uloloi
Sorry, I'm returning to this topic
I am using this smarty to call an image block:
Code: Select all
{content_image block='image_theme' label=$image_dir dir=$image_dir assign='img_slide'}
watching my website print values in the template
{$root_alias} and {$image_dir}, and I see this result
p.e.: section1 and images/mydir
But, in the admin backend, in the page edit section
content_image block doesn't proccess the value of the variable $image_dir, in the label=$image_dir show this result:
$_smarty_tpl->tpl_vars['image_dir']->value:
And select image list shows:
Error retreiving file list.