Announcement

  •  » Extensions
  •  » Show tags block on all pages

#1 2014-10-08 13:32:56

JanisV
Member
2013-09-25
85

Show tags block on all pages

Hi,

Here a code for personal plugin that enable shown tags block in menu on all pages (except picture page) - on main page, categories, etc:

Code:

<?php
/*
Plugin Name: Show tags block on all pages
Version: 1.0
Author: JanisV
*/
 
if (!defined('IN_ADMIN'))
{
  add_event_handler('blockmanager_apply', 'update_block_tags');
}

function update_block_tags($menu_ref_arr)
{
  global $page;
  
  $menu = & $menu_ref_arr[0];
  $block = $menu->get_block('mbTags');
  if ( $block!=null and empty($page['items']) and 'picture' != script_basename() )
  {
    $tags = add_level_to_tags( get_available_tags() );
    foreach ($tags as $tag)
    {
      $block->data[] =
      array_merge( $tag,
        array(
          'URL' => make_index_url( array( 'tags' => array($tag) ) ),
        )
      );
    }

    if ( !empty($block->data) )
    {
      $block->template = 'menubar_tags.tpl';
    }
  }
} 
?>

Piwigo version: 2.7

Offline

 

#2 2014-10-08 17:07:59

flop25
Piwigo Team
2006-07-06
7037

Re: Show tags block on all pages

thx for sharing! :)


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

 

#3 2014-10-15 08:57:25

JanisV
Member
2013-09-25
85

Re: Show tags block on all pages

Version 1.1 with better processing subfolders:

Code:

<?php
/*
Plugin Name: Show tags block on all pages
Version: 1.1
Author: JanisV
*/
 
if (!defined('IN_ADMIN'))
{
  add_event_handler('blockmanager_apply', 'update_block_tags');
}

function update_block_tags($menu_ref_arr)
{
  global $page, $filter;
  
  $menu = & $menu_ref_arr[0];
  $block = $menu->get_block('mbTags');
  if ( $block!=null and empty($page['items']) and 'picture' != script_basename() )
  {
    if (isset($page['category']['id'])) {
      if (!isset($filter['visible_categories']))
        $filter['visible_categories'] = '';
      $old_filter = $filter['visible_categories'];
      $filter['visible_categories'] = $filter['visible_categories'] . implode(',', get_subcat_ids(array($page['category']['id'])));
    }
    $tags = add_level_to_tags( get_available_tags() );
    if (isset($page['category']['id'])) {
      if (empty($old_filter))
        unset($filter['visible_categories']);
      else
        $filter['visible_categories'] = $old_filter;
    }
    foreach ($tags as $tag)
    {
      $block->data[] =
      array_merge( $tag,
        array(
          'URL' => make_index_url( array( 'tags' => array($tag) ) ),
        )
      );
    }

    if ( !empty($block->data) )
    {
      $block->template = 'menubar_tags.tpl';
    }
  }
} 

?>

Offline

 

#4 2015-01-06 23:29:01

somjuan
Guest

Re: Show tags block on all pages

Hi there,

I think I understand exactly what this plugin does, but I can't quite figure out how to install it.  What am I missing?

Thanks

 

#5 2015-01-07 11:52:54

flop25
Piwigo Team
2006-07-06
7037

Re: Show tags block on all pages

hard to tell you since we don't know what you did


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 2015-01-08 03:08:28

somjuan
Guest

Re: Show tags block on all pages

Fair enough :)
I tried following the tutorial here.
Since the code provided seems really meant for only one file, it didn't quite mesh up, but I've tried saving it as both index.php and main.inc.php within its own folder.

 

#7 2015-01-08 08:04:05

flop25
Piwigo Team
2006-07-06
7037

Re: Show tags block on all pages

Use localfiles editor to create your personal plugin And don't forget to enable your 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

 

#8 2020-07-31 08:53:54

MariaAnn
Member
2020-07-31
1

Re: Show tags block on all pages

Very useful. I remember just 3 days ago, I was cofused abot this question.

Offline

 
  •  » Extensions
  •  » Show tags block on all pages

Board footer

Powered by FluxBB

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