| Re: random image in header? possable or no? |
| by mboyden on 2008/12/4 14:20:05 Go back to my original code (without the </div> tag). Do not edit the original function - leave it exactly as is. This function when called allows you to pass the name of the subdirectory of images. What that does is allows you to have more than one set of randomly called images on your page. Each subdirectory will need to have the same size images for this to work, though. The way this is designed, it is THEME-based (the assumption being that if you change themes you likely want to change images). So, in your theme directory (in your case, geometric_red -- I've used this theme myself), make a subdirectory for your images (in your case, 'random', thus XOOPS_ROOT/themes/geometric_red/random). Place your images (all same size) in this subdirectory. Then, make the call passing the name of the subdirectory in the call like this: <img src="<{php}> echo getRndImgURL('random'); <{/php}>" alt="" width="158" height="116" /> Notice that when calling the function, we pass the subdirectory path (inside the theme) of the images. Note, too, that if you have more than one set, you could pass a path, for instance if you have: random/set1 random/set2 random/set3... then the subdirectory passed when calling the function would be 'random/set1', 'random/set2', etc. BTW, make sure you set the width and height to be the size of your pictures. The numbers used in the example I provided were for the particular placement I used. Hopefully I've diluted those muddy waters some? |
| Re: random image in header? possable or no? |
| by ghia on 2008/12/4 12:55:03 To make it less confusing take url images in stead of random. le="color: #000000"><?php <img src="<{php}> echo getRndImgURL('images'); <{/php}>" alt="" width="158" height="116" /> Create a directory /themes/random/geometric_red/images/ (for you: /themes/random/yourthemename/images/)and place there the images to be picked. |
| Re: random image in header? possable or no? |
| by antifmradio on 2008/12/4 5:29:39 i completely get more confused with each answer on this and its not you mboyden forgive me im really good at HTML and some PHP but for some reason i am completely NOT getting this at all so hear me out i need to place this le="color: #000000"><?php <img src="<{php}> echo getRndImgURL('random'); <{/php}>" alt="" width="158" height="116" /> in my header at the location where i want the images to show up the folder where the images are located is called RANDOM the location of this folder is right now inside a specific theme folder "geometric_red" Now just before the code above i post pasted, i need to place this code le="color: #000000"><?php <{php}> function getRndImgURL($path) { // Display Random Image from File Path $i = 0; $dir = @opendir(XOOPS_ROOT_PATH.'/themes/random/'.$GLOBALS['xoopsConfig']['theme_set'].'/'.$path); while ( false !== ($filename = readdir($dir)) ) { if ( preg_match("/(.gif|.jpg|.png)$/", $filename) ) { // image filter $images[$i] = $filename; $i++; } } closedir($dir); mt_srand( (double)microtime() * 1000000 ); $choice = array_rand($images); return XOOPS_URL.'/themes/random/'.$GLOBALS['xoopsConfig']['theme_set'].'/'.$path.'/'.$images[$choice]; } <{/php}> is this correct? please see where the $dir is specified in the second code here. Was i supposed to change it to match? or not. Im looking at the code you pasted just now but im just no getting it i have a code very similar to it and it works on another site ( not XOOPS ) that i administer for someone else. its works and calls exactly the same way create a subdirectory called " random " in "random " place an index.php file with the code in it. goto the page where you want to rotate images call "index.php" using an "image source" function the problem i am having doing that is i cant for the life of me get my "theme.html" to call am image source in the header of this file |
| Re: random image in header? possable or no? |
| by mrphilong on 2008/12/4 5:13:31 Have a look at this script Demo UcChau.Net |
| Re: random image in header? possable or no? |
| by antifmradio on 2008/12/4 4:08:17 Quote:
i guess not. here is what i ended up with i took the insert code and placed it in the header section of theme.html then i went to just before that code still in theme.html and pasted the other part of the code. This is the way it layed out exactly le="color: #000000"><?php <img src="<{php}> echo getRndImgURL('headimages'); <{/php}>" alt="" width="730" height="150" /><br /> <img src="<{php}> echo getRndImgURL('headimages'); <{/php}>" alt="" width="730" height="150" /> but for some reason when i goto my page i see the header but NO images in it i just see the box or table the header is supposed to sit in nothing else on the page shows below the header its all blank with its background color showing |