Random Image question

For discussion and questions related to CMS Specific templates and stylesheets (CSS), and themes. or layout issues. This is not a place for generic "I don't know CSS issues"
Post Reply
Lylel
New Member
New Member
Posts: 5
Joined: Sun Feb 12, 2012 2:16 pm

Random Image question

Post by Lylel »

I'm using Random_image_selective quite a bit and I have two questions.

1. When I use it within the page contents, it "loses" the directory information every time I go back to edit a page. It looks like this - "{random_image_selective dir=" alt="Mic " where the directory path and the closing brace have disappeared. Why? and can I prevent this?

2. One way I'm sure I could prevent this would be to move the Random image into the template, but is there a way I could then specify a different directory for each page?

Thanks!
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: Random Image question

Post by Dr.CSS »

Need way more info...
User avatar
manuel
Power Poster
Power Poster
Posts: 354
Joined: Fri Nov 30, 2007 9:15 am

Re: Random Image question

Post by manuel »

Hi Lylel,

check out this article:
http://www.i-do-this.com/blog/20/Random ... ith-Smarty

Replace

Code: Select all

{assign var='header_images' value='uploads/relative/path/to/images/*.*'|glob}
With

Code: Select all

{assign var='header_images' value='`$somevar`*.*'|glob}
where $somevar will contain the various paths to the folders.

Then you can use $friendly_position to write something like

Code: Select all

{if $friendly_position === "2.1"}{assign var="somevar" value="uploads/relative/path/to/images/"}
{elseif  $friendly_position === "3.1"}{assign var="somevar" value="uploads/relative/path/to/images2/"}
...
ps: if you want to use the same images folder for a certain part of your page tree you can use:

Code: Select all

{$friendly_position|truncate:3:"" === "2.1"}
and it will match 2.1.1, 2.1.2, 2.1.3, ...

I just wrote this down without testing, let me know if you are having trouble implementing it and i'll test it further...

Greetings,
Manuel
lyle
Forum Members
Forum Members
Posts: 13
Joined: Thu Jun 17, 2010 1:12 pm

Re: Random Image question

Post by lyle »

Thanks for responding Manuel,
I'm afraid your approach is a bit over my head.
I'm going to reformulate my question and try re-posting
Post Reply

Return to “Layout and Design (CSS & HTML)”