Announcement

  •  » Extensions
  •  » Recent pics on the other page

#1 2008-08-19 17:30:38

Lum
Guest

Recent pics on the other page

Hi. I have one ask. It is possible to have pictures from the page "Recent pictures" on another page?
I wish to have newest photos from gallery on the main page.

Thanks a lot.

 

#2 2008-08-19 18:33:25

rio
Piwigo Team
Paris
2006-07-24
1431

Re: Recent pics on the other page

Hi Lum,
install the plugin "localfiles editor"
with localfiles editor select tabstrip "personal plugin"
insert

Code:

<?php
/*
Plugin Name: Personnel Plugin
Version: 1.0
Description: Personnel Plugin
Plugin URI: http://www.phpwebgallery.net
Author: P@t
Author URI:
*/

add_event_handler('loc_begin_index', 'personal_get_random_image');

function personal_get_random_image()
{
   global $page, $template;
    
   if (isset($page['section']) and $page['section'] == 'categories' and !isset($page['category']))
   {
      $query = 'SELECT img.path AS path, img.file AS file
                FROM ' . IMAGE_CATEGORY_TABLE . ' AS ic
                INNER JOIN ' . IMAGES_TABLE . ' AS img
                ON ic.image_id = img.id
                WHERE ' . get_sql_condition_FandF(array ('forbidden_categories' => 'ic.category_id'), '', true) . '
                ORDER BY RAND()
                LIMIT 1;';

      $img = mysql_fetch_array(pwg_query($query));
        
      $template->assign_vars(array(
         'PERSONAL_RANDOM_IMAGE' => '<img src="' . $img['path'] . '" alt="' . $img['file'] . '">'));
    }
}

?>

at last, don't forget to activate your personal plugin.

Thx to P@t for this solution.
:-))


-> /<Ä®¿M <-
http://riohome.free.fr
Il forum è anche in ITALIANO

Offline

 

#3 2008-08-19 19:10:37

Lum
Guest

Re: Recent pics on the other page

Thanks for your (very quick) help. :-)

 

#4 2008-08-20 10:17:44

Lum
Guest

Re: Recent pics on the other page

I have additionaly one problem. When I open the file "(...)/plugins/PersonalPlugin/main.inc.php", there's a message- Fatal error: Call to undefined function add_event_handler() in (...)plugins/PersonalPlugin/main.inc.php on line 11 .

What's wrong?

 

#5 2008-08-20 11:20:25

P@t
Piwigo Team
Nice
2007-06-13
4098

Re: Recent pics on the other page

You don't need to open this file!

Install and active LocalFiles Editor.
Copy and past the code into the 5th tab (Personal Plugin)
Then, install and activate the personal plugin in the plugin administration panel.

You also need to install and activate PWG Stuffs
Then, in PWG Stuffs, create a personal block (you can call it "Recent picture" for example)
In this block, you will enter this code to add a random picture:

{PERSONAL_RANDOM_IMAGE}


P@t

Offline

 

#6 2008-08-20 18:36:45

rio
Piwigo Team
Paris
2006-07-24
1431

Re: Recent pics on the other page

Sorry Lum,
I realize that my answer not respond to your question.
In fact, you can simply redirect the first screen to the recent picture page.

with localfiles editor select first tabstrip.
insert

Code:

$conf['random_index_redirect'] = array(
PHPWG_ROOT_PATH.'index.php?/recent_pics' => 'return $user;'
);

You can specify 'return $user[\'is_the_guest\'];' if you want that happen only for guest user.

apologize :-/

:-))


-> /<Ä®¿M <-
http://riohome.free.fr
Il forum è anche in ITALIANO

Offline

 

#7 2008-09-13 17:50:45

Jive Bunny
Member
2007-10-12
50

Re: Recent pics on the other page

This was so easy to set up, but I have a problem.

When I use the secureimages plugin there is no image displayed, I just get the red x with the alt description.

Is there anyway that this could be made compatible? and able to display more than one random image too?

I would even be interested in knowing how to make the php code above display 5 different random images, if possible.

Last edited by Jive Bunny (2008-09-13 17:53:39)

Offline

 
  •  » Extensions
  •  » Recent pics on the other page

Board footer

Powered by FluxBB

github twitter newsletter Donate Piwigo.org © 2002-2024 · Contact