Advanced search  

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Pages: [1]   Go Down

Author Topic: i want show Random pic on my main home page  (Read 3977 times)

0 Members and 1 Guest are viewing this topic.

ahsanch

  • Coppermine newbie
  • Offline Offline
  • Posts: 2
i want show Random pic on my main home page
« on: February 05, 2008, 08:53:55 am »

Hi sir

  i want to show Random Pic on my home page plz gide me

 thx

Regard
 Ahsan Ch (PAK)
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: i want show Random pic on my main home page
« Reply #1 on: February 05, 2008, 09:01:23 am »

Not related to install - moving.
If you mean a non-coppermine-driven page where you want to disply content taken from coppermine, then take a look at the mod board "content syndication". The coppermine dev team recommends using cpmFetch.
Logged

ahsanch

  • Coppermine newbie
  • Offline Offline
  • Posts: 2
Re: i want show Random pic on my main home page
« Reply #2 on: February 06, 2008, 06:07:23 am »

hi sir  Good morning
    sir i can not understand what you say sir plz tell me in detail i m very thanks ful to you.

thx
Regard
Ahsan CH (PAK)
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: i want show Random pic on my main home page
« Reply #3 on: February 06, 2008, 08:32:08 pm »

Link to the sub-board "content syndication": http://forum.coppermine-gallery.net/index.php?board=57.0
Link to the announcement thread for cpmFetch: http://forum.coppermine-gallery.net/index.php?topic=35231.0

If this is a language issue, ask a friend to translate this for you.
Logged

nish

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 23
Re: i want show Random pic on my main home page
« Reply #4 on: February 08, 2008, 05:32:43 pm »

hi...
     use CPMFetch download if from http://cpmfetch.fistfullofcode.com/ and just upload it to your gellery folder use
     http://yourdomain.com/path_to_gallery/install.php
     to install and use

Code: [Select]
  <?php
  
include "./cpmfetch.php";
  
$objCpm = new cpm("./cpmfetch_config.php");
  
$objCpm->cpm_viewRandomAddedMediaFrom(1,4);
  
$objCpm->cpm_close();
   
?>


code
Thanks
Nish
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: i want show Random pic on my main home page
« Reply #5 on: February 08, 2008, 07:59:27 pm »

That set of instructions is too simple. I posted the links to the relevant thread / board. ahsanch needs to read up the docs.
Logged

ib2loud

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Gender: Male
  • Posts: 77
  • I <3 CPG!
    • OKShowPics.com
Re: i want show Random pic on my main home page
« Reply #6 on: February 22, 2008, 11:27:24 pm »

Very cool feature, with a little trial and error I managed to get it working easily and that's saying something for me!
Logged

JohnM-UK

  • Guest
Re: i want show Random pic on my main home page
« Reply #7 on: February 23, 2008, 12:39:43 pm »

Hi. Someone showed me how to do this without using any add-ons. I am currently using it in the 'welcome' section at the top of my gallery page: http://www.oneuk.f2s.com/photos/
Here is the code: (Let's say for this example you are using a file called 'anycontent2.php') (sorry if it's a bit long winded!)
1. Create a folder anywhere on your webserver where you will put your random images, and upload the images you want to use
2. Make a copy of the file 'anycontent.php' and rename it to anycontent2.php
3. Add the following code to this file:

Code: [Select]
<?php

$banners 
= array(=> 'rand1.jpg'=> 'rand2.jpg'=> 'rand3.jpg'=> 'rand4.jpg');

$random rand(1,4); 

$banner "http://www.oneuk.f2s.com/images/rand/" $banners[$random];

echo 
"<p style='text-align: left'><img border=6 src='" $banner "' alt='' /></p>";

?>

Below is a description of the code:

Code: [Select]
<?php

$banners 
= array(=> 'rand1.jpg'=> 'rand2.jpg'=> 'rand3.jpg'=> 'rand4.jpg'); // this is a list all of the image numbers that you will be using and their filenames

$random rand(1,4);  // this is which of the above image numbers you want to use (in this case all of them) so if you have 4 images as I have here you use "(1,4)" if you have 5 images use "(1,5)" for 10 use "(1,10)" etc etc

$banner "http://www.oneuk.f2s.com/images/rand/" $banners[$random]; // this is the folder where your images are located. Change for your server details obviously.

echo "<p style='text-align: left'><img border=6 src='" $banner "' alt='' /></p>";

?>

Now open 'index.php' and find the following code:

Code: [Select]
case 'anycontent':
                        if ($cat == 0) {
                            ob_start();
                            /**
                             * Any php code or HTML can be put in this file and will be displayed
                             */
                            include('anycontent.php');
                            $anycontent = CPGPluginAPI::filter('anycontent',ob_get_contents());
                            ob_end_clean();
                            echo ($anycontent);
                        }
                        flush();
                        break;
and add below it: (basically change all instances of 'anycontent')
Code: [Select]
case 'anycontent2':
                        if ($cat == 0) {
                            ob_start();
                            /**
                             * Any php code or HTML can be put in this file and will be displayed
                             */
                            include('anycontent2.php');
                            $anycontent2 = CPGPluginAPI::filter('anycontent2',ob_get_contents());
                            ob_end_clean();
                            echo ($anycontent2);
                        }
                        flush();
                        break;


That's it, it works for me!
See my gallery: http://www.oneuk.f2s.com/photos/
Refresh the page and the images at the top left of the page will change

Logged

ib2loud

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Gender: Male
  • Posts: 77
  • I <3 CPG!
    • OKShowPics.com
Re: i want show Random pic on my main home page
« Reply #8 on: February 24, 2008, 05:50:38 am »

that's not a bad idea either, but i don't want to re-upload all 7000 images i have in my gallery into another folder

good for those who want a small bit of random images though!
Logged
Pages: [1]   Go Up
 

Page created in 0.03 seconds with 19 queries.