Advanced search  

News:

cpg1.5.46 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter recently discovered vulnerabilities. It is important that all users who run version cpg1.5.44 or older update to this latest version as soon as possible.
[more]

Pages: [1] 2 3   Go Down

Author Topic: Final_Extract - Removing blocks & items like menu buttons  (Read 71824 times)

0 Members and 1 Guest are viewing this topic.

Paver

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 1608
  • Paul Van Rompay
Final_Extract - Removing blocks & items like menu buttons
« on: January 24, 2006, 05:40:37 pm »

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.
Logged

zac

  • Contributor
  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 153
Re: Final_Extract - Removing blocks & items like menu buttons
« Reply #1 on: January 28, 2006, 07:31:33 am »

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
« Last Edit: January 28, 2006, 08:00:07 am by zac »
Logged

Paver

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 1608
  • Paul Van Rompay
Re: Final_Extract - Removing blocks & items like menu buttons
« Reply #2 on: January 28, 2006, 08:12:55 am »

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.
Logged

zac

  • Contributor
  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 153
Re: Final_Extract - Removing blocks & items like menu buttons
« Reply #3 on: January 28, 2006, 08:39:40 am »

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

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

Paver

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 1608
  • Paul Van Rompay
Re: Final_Extract - Removing blocks & items like menu buttons
« Reply #4 on: January 28, 2006, 09:05:43 am »

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.
Logged

zac

  • Contributor
  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 153
Re: Final_Extract - Removing blocks & items like menu buttons
« Reply #5 on: January 28, 2006, 09:32:29 pm »

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 !

Logged

rie

  • Coppermine newbie
  • Offline Offline
  • Posts: 2
Re: Final_Extract - Removing blocks & items like menu buttons
« Reply #6 on: January 29, 2006, 01:36:12 am »

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:
Code: [Select]

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


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

zac

  • Contributor
  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 153
Re: Final_Extract - Removing blocks & items like menu buttons
« Reply #7 on: January 29, 2006, 02:08:02 am »

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

Code: [Select]
// 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

Code: [Select]
<!-- END documentation -->

                        </tr>

                </table>

                </div>



EOT;


oops  ???  dont do that.  when i logged out of admin I got a whole lot of errors *yikes*
« Last Edit: January 29, 2006, 02:13:43 am by zac »
Logged

Paver

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 1608
  • Paul Van Rompay
Re: Final_Extract - Removing blocks & items like menu buttons
« Reply #8 on: January 29, 2006, 02:12:55 am »

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.
Logged

rie

  • Coppermine newbie
  • Offline Offline
  • Posts: 2
Re: Final_Extract - Removing blocks & items like menu buttons
« Reply #9 on: January 29, 2006, 02:14:50 am »

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
Logged

zac

  • Contributor
  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 153
Re: Final_Extract - Removing blocks & items like menu buttons
« Reply #10 on: January 29, 2006, 02:15:43 am »

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

Paver

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 1608
  • Paul Van Rompay
Re: Final_Extract - Removing blocks & items like menu buttons
« Reply #11 on: January 29, 2006, 02:17:03 am »

@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.
Logged

zac

  • Contributor
  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 153
Re: Final_Extract - Removing blocks & items like menu buttons
« Reply #12 on: January 29, 2006, 02:34:16 am »

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.. :

Code: [Select]
//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;
}
« Last Edit: January 29, 2006, 04:54:04 am by zac »
Logged

Kugelblitz

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 45
Re: Final_Extract - Removing blocks & items like menu buttons
« Reply #13 on: January 31, 2006, 07:13:29 am »

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

Code: [Select]
<?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;
}

?>
Logged

Paver

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 1608
  • Paul Van Rompay
Re: Final_Extract - Removing blocks & items like menu buttons
« Reply #14 on: January 31, 2006, 08:17:15 am »

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).
Logged

Kugelblitz

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 45
Re: Final_Extract - Removing blocks & items like menu buttons
« Reply #15 on: February 02, 2006, 06:59:09 am »

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  ;)
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47844
  • aka "GauGau"
    • gaugau.de
Re: Final_Extract - Removing blocks & items like menu buttons
« Reply #16 on: February 02, 2006, 09:32:34 am »

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

markp17

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 56
Re: Final_Extract - Removing blocks & items like menu buttons
« Reply #17 on: February 06, 2006, 11:22:11 pm »

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
Logged

Nibbler

  • Guest
Re: Final_Extract - Removing blocks & items like menu buttons
« Reply #18 on: February 06, 2006, 11:23:34 pm »

The link is on the config page, 'Manage plugins'.
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47844
  • aka "GauGau"
    • gaugau.de
Logged
Pages: [1] 2 3   Go Up
 

Page created in 0.024 seconds with 21 queries.