random background image within generated module

Everything to do with Joomla! 1.5 templates and templating.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Locked
User avatar
Shinteetah
Joomla! Apprentice
Joomla! Apprentice
Posts: 22
Joined: Thu Jun 05, 2008 6:26 pm

random background image within generated module

Post by Shinteetah » Sun Jun 08, 2008 5:36 am

I have no idea if this is even possible, but how else do I learn? :) (I did search here and elsewhere first.)

I am using a template which illustrates a div with a background image. I would like for this particular class of div to have a *different* background image each time.

I have a script which will generate the random image I need. I know how to call the script from a static element (say, a footer) by inserting the call into the static footer div code. However, these divs are generated dynamically (featured articles on a front page) and have no "hard code" into which I can insert script tags.

My thought is that it might be possible to define the div attributes somehow in the CSS, but I have no idea how to write that correctly. (I am a total klutz at javascript.) Or, there might be another solution I'm not aware of.

For the purposes of this discussion, let's say I'm using the readily-available Beez template (in Joomla! 1.5.3), and it's the "leading" div to which I want to add the random background image. The leading div attributes are defined in position.css.

Thanks for any help!
Last edited by Shinteetah on Mon Jun 09, 2008 6:26 am, edited 1 time in total.

User avatar
Shinteetah
Joomla! Apprentice
Joomla! Apprentice
Posts: 22
Joined: Thu Jun 05, 2008 6:26 pm

Re: call javascript from CSS attributes?

Post by Shinteetah » Mon Jun 09, 2008 4:58 am

Okay, I am trying to call the script from the php file writing the "leading" div itself.

It's written as this:

Code: Select all

<div class="leading<?php echo $this->params->get('pageclass_sfx'); ?>">
			<?php $this->item =& $this->getItem($i, $this->params);
			echo $this->loadTemplate('item'); ?>
		</div>
and I am trying to insert

Code: Select all

<script language="JavaScript">
showImage();
</script>
somewhere in there. So far I haven't broken anything, but neither can I get the script to work correctly. Any help?

User avatar
Shinteetah
Joomla! Apprentice
Joomla! Apprentice
Posts: 22
Joined: Thu Jun 05, 2008 6:26 pm

Re: call javascript from CSS attributes?

Post by Shinteetah » Mon Jun 09, 2008 6:25 am

Oh, the things I am learning!

Apparently my random image script is competing with another script, so that option is no longer viable.

I did find this tantalizing reference elsewhere in the forums:

Code: Select all

   background: url(../images/logos/rotate.php);
but I cannot find any information on locating even that code, much less a similar random.php.

In desperation I tried

Code: Select all

background: url(http://site.com/modules/mod_random_image/mod_random_image.php) ;
but without success.

Any comments, now that I've come this far?

User avatar
Shinteetah
Joomla! Apprentice
Joomla! Apprentice
Posts: 22
Joined: Thu Jun 05, 2008 6:26 pm

Re: random background image within generated module

Post by Shinteetah » Mon Jun 09, 2008 3:44 pm

Found another script through the wonder of Google, and this one works very well indeed. So issue solved and site live.

merlin2001
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Fri Jul 04, 2008 4:49 am

Re: random background image within generated module

Post by merlin2001 » Fri Jul 04, 2008 4:56 am

Hi,

i´v got the same Problem, so it would be nice, if you woud tell me, how you solved the Problem, or tell me the script name and where i can it download.

Greetings Merlin

User avatar
Shinteetah
Joomla! Apprentice
Joomla! Apprentice
Posts: 22
Joined: Thu Jun 05, 2008 6:26 pm

Re: random background image within generated module

Post by Shinteetah » Fri Jul 04, 2008 5:42 am

I hit up Google for another rotate.php and used it instead. I'm sorry, I don't remember the exact source; I found several.

merlin2001
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Fri Jul 04, 2008 4:49 am

Re: random background image within generated module

Post by merlin2001 » Fri Jul 04, 2008 6:00 am

I´v found the rotate.php, but it doesnt´t displa the Image in the Background, means the image shows up at the top of the page and after that the content of the page. do you remeber how to insert the code into the site?

Merlin

User avatar
Shinteetah
Joomla! Apprentice
Joomla! Apprentice
Posts: 22
Joined: Thu Jun 05, 2008 6:26 pm

Re: random background image within generated module

Post by Shinteetah » Fri Jul 04, 2008 6:17 am

In my CSS I defined

Code: Select all

background: url(http://site.com/directory/rotate.php) ;
and then I called that style within the div in the story. Does this make sense?

merlin2001
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Fri Jul 04, 2008 4:49 am

Re: random background image within generated module

Post by merlin2001 » Mon Jul 07, 2008 8:50 am

Thank you, this makes sense an works well.

Merlin


Locked

Return to “Templates for Joomla! 1.5”