Final_Extract - Removing blocks & items like menu buttons Final_Extract - Removing blocks & items like menu buttons
 

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

Main Menu

Final_Extract - Removing blocks & items like menu buttons

Started by Paver, January 24, 2006, 05:40:37 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Paver

donnoman posted a handy plugin in this thread: http://forum.coppermine-gallery.net/index.php?topic=25197.0.

The final_extract plugin removes core blocks from the final HTML produced by Coppermine, just before it is displayed to the user on the web page.  This is probably the best way to remove things like menu buttons and other core items like links & buttons throughout the various pages Coppermine produces.

This thread will serve as a central place to find this plugin and for further development.

Version 1.0 removes the 'login' and 'home' buttons on the SYS_MENU.  If you want to remove others with this version, you need to add the blocks manually to codebase.php using the 'login' and 'home' lines as examples.

If no one else does so, I plan to put together a config panel for this plugin so you can choose other blocks without modifying plugin code.  donnoman and other devs are welcome to modify this post & thread as desired.

zac

Hi... not sure if I am in the right place but I want to remove the menu buttons.  I tried this plugin but dont really know what i am doing.  I have used coppermine for a couple years but just got 1.4.3 last night.  Anyways.. i ftp the plugin to the folder... i turned it on in admin.. now what?  I basically want to remove all of those links.  How does this work?

*edit* nevermind.. i just commented the whole thing out in my template.html

Paver

If you want to remove the whole menus, then commenting them out in template.html is the best way.  I don't use the SUB_MENU myself so I merely removed it.  (I created a custom SYS_MENU with all the buttons I need.)

This plugin currently removes the Home and Login buttons.  There's no configuration panel.  If you want to remove any others, you have to modify codebase.php of the plugin.

zac

thanks Paver!  The menu is gone in Firefox but still there in IE !?  weird  ???

check it out ... http://www.folkphotography.com/shop/

Paver

Yeah, this is a common issue.  What's happening is that you have nested comments.  You commented out the SYS_MENU in template.html, but the SYS_MENU tag is replaced with HTML which includes its own comments.  Firefox can understand the nested comments (which takes extra work keeping track of all the begin & end comment markers), but IE merely closes all comments when it comes to an end comment marker, no matter how many begin comment markers came before (due to nesting).

I suspected this might happen, so that's why I mentioned removing the things you don't want from template.html.  I thought you had it working so didn't explicitly mention the comment issue.

Nice-looking website!  I don't know if there's any easy way for you to make your theme generic and submit it as a theme contribution.  If you feel like it, it would be a nice way to share your theme.  If you don't think you have time, you could contribute what you have and maybe someone will volunteer to make it generic using category placeholders or the like, probably putting the menus back in some coherent way.  If you would like to keep the theme to yourself, that's perfectly understandable as well.

zac

ok .. I will just start tweaking the theme.. I am starting to understand this new version a little bit.. many thanks.  Glad you like my site :) it still has a ways to go as when I am done modifying it there will be little remaining.  I am going for very minimalist even though it is hard to give up a lot of the functionality of cpm.   I will eventually try to share my theme hack as I never would have been able to do it without all of the awesome sharing and teaching that goes on in this community and at Pixelpost (where I got the Sugar template that my site is based on). Right now I am trying to install Dennis's paypal hack.. if my head doesnt explode during that I will strip my theme generic and try to figure out a layout for all of the links that come stock.

Cheers !


rie

Thanks for this..

I had something I wanted to remove but was having troubles figuring out where. 

I altered it slightly for my use. 
I made it:


if (!USER_ID) {  final_extract_block ($html,'favpics');}



So that some of the menu items are unavailable if you are not logged in.

zac

not sure what you are trying to remove rie...I fixed by copying from the sample theme to my theme and commenting out each link that I did not want..

I copied from sample starting at line 113

// Creates buttons from a template using an array of tokens

// this function is used in this file it needs to be declared before being called.



and ending with this at line 363

<!-- END documentation -->

                        </tr>

                </table>

                </div>



EOT;



oops  ???  dont do that.  when i logged out of admin I got a whole lot of errors *yikes*

Paver

I think rie's point was that it was easier to add one line to the plugin than to find the block in the theme to remove.  There are a lot of blocks in the theme that you can remove there, but this plugin is dirt-simple to add one line and remove it in the final HTML.  It is true that it's less efficient to create the code, then remove it at the end before it is displayed, but the performance hit must be negligible except in very few extreme-traffic cases, I would think.

rie's addition suggests an addition to this plugin to allow configuration of anonymous vs. logged-in removal of blocks.  I can easily add that to my working version and put it into the next release.

rie

Yes what Paver said.

I started with the rainy_day theme and was going to tweak that.
Once I saw this plugin, I figured it would be easier to do it here.    I was guessing that this should cover all themes.

Roger

zac

hmmm i need dirt simple .  i will take another look at this plugin.

Paver

@rie: Yes, that's a good point - this covers all themes.  There's also a master template plugin which can be used for similar "all themes" theme modifications.

zac

ah finally i got it..  great plugin Paver. and your addition too rie... (catching on a little late)Thanks !  I added this to get rid of everything.. :


//repeat the next line for each block you would like removed
      final_extract_block($html, 'my_gallery');
  final_extract_block($html, 'my_profile');
  final_extract_block($html, 'upload_pic');
  final_extract_block($html, 'lastup');
      final_extract_block($html, 'toprated');
      final_extract_block($html, 'favpics');
      final_extract_block($html, 'home');
  final_extract_block($html, 'search');
  final_extract_block($html, 'login');
  final_extract_block($html, 'lastcom');
  final_extract_block($html, 'album_list');
  final_extract_block($html, 'topn');

return $html;
}

Kugelblitz

Cool Plugin, but I still can not hide the Buttons

home, lastcom, topn and favpics

Any Suggestions?

Thanks for help



here is my codebase.php

<?php
/*************************
  Coppermine Photo Gallery
  ************************
  Copyright (c) 2003-2005 Coppermine Dev Team
  v1.1 originaly written by Gregory DEMAR

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.
  ********************************************
  Coppermine version: 1.4.1
  $Source: /cvsroot/cpg-contrib/master_template/codebase.php,v $
  $Revision: 1.3 $
  $Author: donnoman $
  $Date: 2005/12/08 05:46:49 $
**********************************************/

if (!defined('IN_COPPERMINE')) die('Not in Coppermine...');

$thisplugin->add_filter('page_html','final_extract_page_html');

function 
final_extract_block(&$template$block_name$subst='')
{
        
$pattern "#(<!-- BEGIN $block_name -->)(.*?)(<!-- END $block_name -->)#s";
        if ( 
preg_match($pattern$template$matches)){
            
$template str_replace($matches[1].$matches[2].$matches[3], $subst$template);
            return 
$matches[2];
        }
}

function 
final_extract_page_html($html)
{   
    
//repeat the next line for each block you would like removed
 
final_extract_block($html'home');
        
final_extract_block($html'my_gallery');
final_extract_block($html'allow_memberlist');
final_extract_block($html'my_profile');
final_extract_block($html'enter_admin_mode');
final_extract_block($html'leave_admin_mode');
final_extract_block($html'register');
 
//     final_extract_block($html, 'faq');
 // final_extract_block($html, 'login');
 // final_extract_block($html, 'logout');
 // final_extract_block($html, 'custom_link');
final_extract_block($html'album_list');
final_extract_block($html'lastup');
final_extract_block($html'lastcom');
final_extract_block($html'topn');
final_extract_block($html'toprated');
final_extract_block($html'favpics');
final_extract_block($html'search');

return $html;
}

?>

Paver

What theme are you using?  If you customized your theme or are using a theme where the "My Favorites" link is not properly bracketed by the 'favpics' tags, then this plugin cannot find that link.  You can also look at "View Source" for your webpage to see if the links are properly bracketed.  If you look in the sample/theme.php, you'll see how the system menu buttons are supposed to be tagged.

If those links are not properly bracketed, you can either bracket them properly and use this plugin, or just remove those links manually.  It's safer to use the plugin since other parts of Coppermine may look for those links, but if they aren't bracketed properly now and Coppermine hasn't complained, maybe you are safe.  Then again, some condition may have Coppermine looking for them.  I just checked and 'favpics' is not used by Coppermine anywhere so that one is safe to manually delete.  But I guess it's still better to use the plugin to remove it to make it easier to put it back if you want or for future versions (although that's thinking a bit ahead).

Kugelblitz

I am customizing a theme with images as Menu Buttons.

I solved my "Remove Button" Problem with reading this Thread
http://forum.coppermine-gallery.net/index.php?topic=25197.0

Would be cool to have an option "show x Button          [ ]Yes [X]No" in the next release.

I sometimes had the problem that I could not login into my page when the Plugin was activated. Had to change the "execute" Right for the Plugin Folder by using a FTP Programm.
Didn't know why. No Error Message appeared.
It works for now.

Thanks for the Plugin and Your Help  ;)

Joachim Müller

all PHP files need read/execute permissions to run, that's expected behaviour.

markp17

ok, got it working, however there was no link to the plugin manager, so had to link directly to it from browser.. strange but could not find the link.

thanks anyway it works

Nibbler