Home arrow Forum displaying different images in divs
  Welcome, Guest. Please login or register.
Did you miss your activation email?
November 22, 2008, 06:23:24 PM
Home New Posts Search Calendar


Login with username, password and session length
+  Joomla Forum
|-+  Joomla Hacks
| |-+  FAQ's
| | |-+  displaying different images in divs
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Go Down Print
Author Topic: displaying different images in divs  (Read 1459 times)
shawna
Joomla Newbie
*

Karma: +0/-0
Offline Offline

Posts: 2


View Profile
displaying different images in divs
« on: January 28, 2007, 08:17:08 PM »

Hey Everyone,

I am hoping someone can help me.  I am new to the whole Joomla thing, and I have uploaded my own template.  Right now, I have it so that my own content can display.  But I would also be able to have a div that displays purely images.  So kinda like how the mosMainBody switches on each page, I would like something similar for images.  Does this make sense? 

My site is done in divs...so the content is in one div.  the image in another div right beside it.  but the image needs to switch on each page.  so there is an about us image, contact image, etc.

Any insight would be awesome!!

Thanks,
Shawna
Logged
joomlanewbie
Joomla Master
***

Karma: +20/-5
Offline Offline

Posts: 145


View Profile
Re: displaying different images in divs
« Reply #1 on: January 29, 2007, 01:43:02 AM »

In your index.php for your template, you can OVERRIDE the image attribute (or any attribute of any CSS element) for your pages by acting on the value of
getenv("REQUEST_URI")

(for THIS page you are viewing, getenv("REQUEST_URI") should be

Code:
/component/option,com_smf/Itemid,94/action,post/topic,3236.0/num_replies,1

It looks that way because SEF URL rewriting is in place. Regardless, in either situation, you would see if "com_smf" is IN getenv("REQUEST_URI") and set your image background accordingly!

As a matter of fact, why limit yourself to an image switch? you could logically switch all kinds of stuff around, colors, font size, javascript: you name it!

EXAMPLE:
Code:
<?php
$user_action 
getenv("REQUEST_URI");
$custom_css="";

IF (
strpos($user_action "com_smf") ) $custom_css ="<style>body {background-image: url(../images/forum.gif); background-repeat: repeat-y;width: 150px;}</style>";

IF (
strpos($user_action "com_content") ) $custom_css ="<style>body {background-image: url(../images/content.jpg)}; </style>";

echo 
$custom_css;
?>


(or the echo statement may be somewhere else, depending on how you have the template code done, and then you would have something like..

Code:
<?php echo $custom_css;?>


let us know how you make out!


*by that I mean, let us know the success you have with the technique, not your "make out skills"!

Cheesy
Logged
shawna
Joomla Newbie
*

Karma: +0/-0
Offline Offline

Posts: 2


View Profile
Re: displaying different images in divs
« Reply #2 on: January 29, 2007, 09:17:11 AM »

What if it is an image I want to display through Joomla...meaning its dynamic and I can change it at anytime without having to go through the code?
Logged
joomlanewbie
Joomla Master
***

Karma: +20/-5
Offline Offline

Posts: 145


View Profile
Re: displaying different images in divs
« Reply #3 on: February 04, 2007, 08:32:25 PM »

What if it is an image I want to display through Joomla...meaning its dynamic and I can change it at anytime without having to go through the code?

what exactly do you mean? unless you exert your psychic powers, how else are you going to change it if not through code?

maybe if you specify exactly what you want to do and how you want it to happen?

taking a wild guess, lets say you want a gallery type response where people click on a button and they see an appropriate image in your DIV, then you could have several buttons

[btn 1] On click div1.innerhtml='<img src="image1.jpg">'
[btn 2] On click div1.innerhtml='<img src="image2.jpg">'
[btn 2] On click div1.innerhtml='<h1>No Image! just a big heading!</h1>'

that way you update the image or contents of the div based on user input.


What if you just want to display a RANDOM image each time? without having to tell the code to display an image??


then in that case, you will have a folder for your images, read the directory to get a count of images in there, then use a random function to choose a particular image.

Logged
Pages: [1] Go Up Print 
« previous next »
Jump to:  



Login with username, password and session length

Powered by MySQL Powered by PHP Joomla Forum | Powered by SMF 1.1 RC1.
© 2001-2005, Lewis Media. All Rights Reserved.
Joomla Bridge by JoomlaHacks.com
Valid XHTML 1.0! Valid CSS!

Joomla Hacks is a Joomla Components, Joomla Modules, Joomla Templates, & Joomla Mambots resource portal. None of the text or images in this public website may be copied without the expressed written consent of the authors. Copyright 2005 by JoomlaHacks.com. Powered by Joomla. All rights reserved.
Terms of Use
Joomla Hacks



Joomla Hacks
German Lang French Lang Italian Lang Spanish Lang Japanese Lang Chinese Lang
Search Contact About Advertise Blogs Topsites Submit News Register Login