Announcement

#1 2011-06-24 01:23:28

nicksclick
Member
2011-06-10
5

How to skip albums, going straight to pics

Hello! I'd like to invert the normal navigation order of my gallery.

I'm wondering if there is a way to go directly to photos after clicking on a category.

Then, if the visitor would like to see the whole set of pics, he could browse to the album or category (they are the same thing, am I right?).
What kind of hack could I do?

I'm using Piwigo v2.2.3 and the Stripped theme.

Last but not least thanks for the great software and for keeping it free! :)

nick

Offline

 

#2 2011-06-24 22:37:57

nicksclick
Member
2011-06-10
5

Re: How to skip albums, going straight to pics

I spent all day searching the forum, the wiki and dissecting the template files with no luck.
I just found at the beginning of mainpage_categories.tpl this line of code

Code:

<a href="{$cat.URL}"> ... </a>

that points to the thumbnails page. I tried playing with it like

Code:

<a href="{$cat.URL.thumbnail.URL}"> ... </a>
<a href="{$cat.thumbnail.URL}"> ... </a>

but I got only errors or nothing.
My knowledge is very limited in that stuff, I don't  know where to go.
Any suggestion?

Offline

 

#3 2011-06-24 22:41:04

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13175

Re: How to skip albums, going straight to pics

1) install and activate plugin [extension by Piwigo Team] Extended Description
2) if you have photo 123 in album 4, then in the description of album 4, write [redirect img=123.4]

I confirm: category = album.


Latest blog post (May 3rd 2018) New subscription form

Offline

 

#4 2011-06-25 14:40:42

nicksclick
Member
2011-06-10
5

Re: How to skip albums, going straight to pics

Thanks for your help, I'm near my goal!

Maybe I misunderstood your advice about the input for the 'Description' field, anyway writing

Code:

[redirect picture.php?/1/category/1]

did the trick, but now the breadcrumb points to the redirected link, that is the beginning of the album, and not to the thumbnails page. I'm on half of my way.
Am I doing something wrong or this is the way the plugin it's supposed to work?

Here is my site under construction http://nicksclick.net/

Last edited by nicksclick (2011-06-25 14:41:25)

Offline

 

#5 2011-06-25 18:25:26

flop25
Piwigo Team
2006-07-06
6851

Re: How to skip albums, going straight to pics

with that code, when the category is going to be displayed, the page is redirected to the link chosen (here picture.php?/1/category/1).
So you can't go back the upper level (the album) because it will always be skipped/redirected... To do what you want, you need a plugin. With localfiles editor, make a personal plugin. Something like :

Code:

add_event_handler('loc_end_index_category_thumbnails', 'skip_cat');
function skip_cat($tpl_thumbnails_var)
{
    global $template;
      $new_tplvar=array();
    foreach ($tpl_thumbnails_var as $tplvar)
    {
      
$url = duplicate_picture_url(
        array(
          'image_id' => $category['representative_picture_id'],
        ),
        array('start')
      );
$tplvar['URL']=$url;
    }
    return $tplvar;

}

To get a better help : Politeness like Hello-A link-Your past actions precisely described
Check my extensions : more than 30 available
who I am and what I do : http://fr.gravatar.com/flop25
My gallery : an illustration of how to integrate Piwigo in your website

Offline

 

#6 2011-06-26 12:20:33

nicksclick
Member
2011-06-10
5

Re: How to skip albums, going straight to pics

Hi flop25, thanks for your help. I tried your code but nothing happened. Saying "something like" I guess it needs some refining, but being a totally ignorant in programming,  I don't know how to adjust it.
More hints are welcome! ;D

OT: it's curious, I tried many gallery softwares but I never found one with this "reverse" navigation order. I wonder, is so unusual?
PS: how do I turn on smilies?

Offline

 

#7 2011-06-26 12:55:41

flop25
Piwigo Team
2006-07-06
6851

Re: How to skip albums, going straight to pics

yep it's unsual
here there is no smiley

I'll work on it. yesterday I had no time


To get a better help : Politeness like Hello-A link-Your past actions precisely described
Check my extensions : more than 30 available
who I am and what I do : http://fr.gravatar.com/flop25
My gallery : an illustration of how to integrate Piwigo in your website

Offline

 

#8 2011-06-29 19:54:06

flop25
Piwigo Team
2006-07-06
6851

Re: How to skip albums, going straight to pics

wow it was harder than I thought !!
try that please :

Code:

add_event_handler('loc_end_index_category_thumbnails', 'skip_cat');
function skip_cat($tpl_thumbnails_var)
{
  include_once(PHPWG_ROOT_PATH.'include/functions_picture.inc.php');
  global $template, $page, $conf;
  $new_tplvar=array();
  foreach ($tpl_thumbnails_var as $tplvar)
  {
    if(preg_match_all('/(?<=thumbnail\/TN-)\X+?(?=\.)/i', $tplvar['TN_SRC'],$result))
    {
    $url="picture.php?".$result[0][0];
    $tplvar['URL']=$url;
    }
    $new_tplvar[]=$tplvar;
  }
  return $new_tplvar;
}

don't forget to activate your Personal plugin ;)


To get a better help : Politeness like Hello-A link-Your past actions precisely described
Check my extensions : more than 30 available
who I am and what I do : http://fr.gravatar.com/flop25
My gallery : an illustration of how to integrate Piwigo in your website

Offline

 

#9 2011-06-29 19:57:58

flop25
Piwigo Team
2006-07-06
6851

Re: How to skip albums, going straight to pics

ha it's not working with uploaded picture :/
well... Need some help over here !


To get a better help : Politeness like Hello-A link-Your past actions precisely described
Check my extensions : more than 30 available
who I am and what I do : http://fr.gravatar.com/flop25
My gallery : an illustration of how to integrate Piwigo in your website

Offline

 

#10 2011-06-30 09:46:10

nicksclick
Member
2011-06-10
5

Re: How to skip albums, going straight to pics

I'm very busy these days, so take it easy :)
When I'll have more the 5 minutes I'll be back and test your input.
I'm glad to see there is some interest in this topic. I'm sure I will not be the only one appreciating a successful result!
Thank you for your time!

Offline

 

#11 2011-09-15 02:07:21

blowdoof
Member
1970-01-01
4

Re: How to skip albums, going straight to pics

Was having the same issue, and as a newbie to piwigo, started searching as well.
Took me some time, and i'm sure this is far from excellent, but it does work
However, instead of using a redirect, i'd prefer just a straight goto.. no idea how to achieve however :(

well, here is what i wrote:

Code:

if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');

function parse_extended_desc($desc, $param='')
{
  global $conf, $page;
      
  if ($param == 'main_page_category_description' and isset($page['category']) and !isset($page['image_id']) and preg_match('#\[rebuild (.*?)\]#i', $desc, $m1))
  {
    
  $array = $page['category'];
  $key = 'id'; 
  $categ = $array[$key]; 
    
   $baseurl = PHPWG_ROOT_PATH; 
   $url = PHPWG_ROOT_PATH.'picture.php?/';
        
   $query = '
  SELECT
    image_id
  FROM '.IMAGE_CATEGORY_TABLE.'
  WHERE category_id = '.$categ.'
  ORDER BY rank DESC
  LIMIT 1
;';
    
  $result = pwg_query($query);
  while ($row = pwg_db_fetch_assoc($result))
  {
    $theimage = $row['image_id'];
  }

    if (!$theimage > 0)
    {
     $redurl = $baseurl;
    }
    else
    {    
    $redurl = $url.$theimage.'/category/'.$categ;
    }
      
    redirect($redurl);
    
  }
   
}

add_event_handler ('render_category_description', 'parse_extended_desc', EVENT_HANDLER_PRIORITY_NEUTRAL, 2);

Oh, one more thing.. didn't handle the case where you don't put any comment on the album.. it somehow gives me a 'you're not allowed page', but i really need to get some sleep now, if somebody could fixed it ?

Last edited by blowdoof (2011-09-15 02:08:00)

Offline

 

#12 2011-09-15 16:34:04

flop25
Piwigo Team
2006-07-06
6851

Re: How to skip albums, going straight to pics

hello

blowdoof wrote:

Oh, one more thing.. didn't handle the case where you don't put any comment on the album..

you means "picture" instead of "comment" ?

blowdoof wrote:

it somehow gives me a 'you're not allowed page',

yes, and this is the top of the iceberg, because having the right "representative picture" is much more complicated : the id of this picture is stored in database in pwg_user_cache_categories, but if the admin change the rights or delete the picture, we need to choose again another one. This is done in include/category_cats.inc.php line 196-269.
So it would much easier to have this feature addded : [Bugtracker, ticket 2397, fixed] Adding more fields for template usage for representative thumbnails


To get a better help : Politeness like Hello-A link-Your past actions precisely described
Check my extensions : more than 30 available
who I am and what I do : http://fr.gravatar.com/flop25
My gallery : an illustration of how to integrate Piwigo in your website

Offline

 

#13 2011-09-15 18:19:03

blowdoof
Member
1970-01-01
4

Re: How to skip albums, going straight to pics

no, i mean comment. (comment on album).
Whole point is skipping the thumbs and going straight to the image from the menu (album menu made)

And all pics are set to public, so that's not the issue neither.
But i hate that redirect. It should just change the request uri instead of going trough that redirect

Offline

 

#14 2011-09-15 18:27:18

flop25
Piwigo Team
2006-07-06
6851

Re: How to skip albums, going straight to pics

comments on album are available threw a plugin only ! or maybe you talk about the description... whatever, I don't understand why it's a problem : what do you expect ?


to change the link use my code and yours with $tplvar['ID'] instead of $page['category']['id']


To get a better help : Politeness like Hello-A link-Your past actions precisely described
Check my extensions : more than 30 available
who I am and what I do : http://fr.gravatar.com/flop25
My gallery : an illustration of how to integrate Piwigo in your website

Offline

 

#15 2011-09-15 20:02:14

blowdoof
Member
1970-01-01
4

Re: How to skip albums, going straight to pics

I did indeed ment the description, not comment, my mistake.
About your $tplvar : should i call it by using the redirect function as well? or is there another function to recreate the url (so catch the original requested url and rewrite it before being handled), since the redirect first loads the redirect page and then goes to the final page... tried with the 'return', but that just shows the url on the page instead of loading it. Or am i intercepting the wrong event?

Perhaps the site itself can make it more clear: http://www.geertvandeneede.com

Thx for the help, appreciate it a lot. And i must say i love the way piwigo framework is build, just trying to figure it out more (read through the entire docs)

Offline

 

Board footer

Powered by FluxBB

github twitter facebook google+ newsletter Donate Piwigo.org © 2002-2018 · Contact