different dir to content_image

The place to talk about things that are related to CMS Made simple, but don't fit anywhere else.
Post Reply
uloloi
Forum Members
Forum Members
Posts: 88
Joined: Thu Dec 16, 2010 8:50 pm

different dir to content_image

Post 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
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: different dir to content_image

Post 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}
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.
uloloi
Forum Members
Forum Members
Posts: 88
Joined: Thu Dec 16, 2010 8:50 pm

Re: different dir to content_image

Post 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.
uloloi
Forum Members
Forum Members
Posts: 88
Joined: Thu Dec 16, 2010 8:50 pm

Re: different dir to content_image

Post 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.
Post Reply

Return to “The Lounge”