• Gear
  • Shots
  • Photo Craft
  • Video
  • Wide Angle
  • Support
  • New Stuff
  • More
Support SmugMug Customization Hiding menu items - style menu, share menu

FAQtoid

Ever wanted to create an Avatar? Creating an Avatar!

Searching Dgrin with Google Searching with Google

Dgrin Challenges

Congratulations to the Winner of DSS #128 (Sunrise or Sunset), ShootingStar.

The next Dgrin Challenge DSS #129 (Silhouette Revisited ) is open for entries through May 27th, 2013 at 8:00pm PDT.

As always, we look forward to your participation but please do take a moment to read through the rules before posting your entry.

Past DSS Challenge Winners, DSS Challenge Rules, and other important DSS Challenge information is here.

Need some help with Accessories?

Tutorials

Ever find yourself wondering just how someone managed to create an image using different effects?

Here are three simple tutorials we hope will encourage you to try something new.

The Hot Seat

A lifelong interest in landscape photography has led Eyal Oren to make a study of his adopted hometown of Marblehead, MA. As you can see, his dedication is paying off!

Africa!

Dgrinners Harryb, Pathfinder, and others joined Andy Williams and Marc Muench on Safari in East Africa recently. Here are some awesome threads to check out!

 
Thread Tools Display Modes
Page 1  of  3
1 2 3
Old Aug-09-2009, 10:14 PM
#1
jfriend is offline jfriend OP
Scripting dude-volunteer
Hiding menu items - style menu, share menu, buy menu
This describe a customization that allows you to hide any menu item in the style menu (to only offer certain viewing styles) or in the Share menu (to only offer certain sharing options) or the Buy menu (particularly to hide the Buy All Digital Downloads menu item).

For example, you could change the style menu from this:



to this:




To use this, there are simply two steps:

Step 1

Copy this code into your bottom javascript:

Code:
//------------------------------------------------------------------------------------------------------------------------------------------
// Script to allow you to use CSS to hide any individual menu items in the Share or Style menus
// This script will add a class name to each top level menu item in the Share and Style menus.
// That class name will be of the form "buttonname_menuitemname_menuitem".
// The class name will be all lowercase and any spaces or other non-alpha numeric chars in it will be converted to underscores.
// Here are some examples of class names:
//    share_be_social_menuitem
//    share_social_bookmarking_menuitem
//    style_traditional_menuitem
//
// And some example CSS to hide a menu item would look like this:
//    .share_be_social_menuitem {display:none;}
//    .style_traditional_menuitem {display:none;}
//
// You can also hide menu items only in certain contexts using all the normal Smugmug CSS classifiers. 
// To hide social bookmarking only in your vacation category, you would use CSS like this:
//    .category_Vaction .share_be_social_menuitem {display:none;}
//
// Version 1.1
//------------------------------------------------------------------------------------------------------------------------------------------

YE.onContentReady("viewingStylesButton", TagMenuItemsSetup);
YE.onContentReady("shareButton", TagMenuItemsSetup);
YE.onContentReady("buyButton", TagMenuItemsSetup);

function TagMenuItemsSetup()
{
    // now that the object is created, we can register an interest in the beforeShowEvent
    // we can't modify the menu until then because of lazyLoading
    var button = YAHOO.widget.Button.getButton(this.id);
    var menu = button.getMenu();
    if (!menu) return;
    var menuName = button.get("label");
    menu.beforeShowEvent.subscribe(TagMenuItems);
    
    function TagMenuItems(event, args, data)
    {
        // called in the context of the menu
        try
        {
            // get the list of menu items in our menu
            var menuItems = this.getItems();
            
            // look through each menu item to see if it matches anything in our stylesToRemove array
            for (var i = 0; i < menuItems.length; i++)
            {
                // get the text value from the menu item and make it into a new class name
                var newClassName = menuItems[i].cfg.config.text.value;
                newClassName = menuName + "_" + newClassName + "_menuitem";
                newClassName = newClassName.replace(/\s+|\&[a-z]+;|[^_a-zA-Z0-9-]/g, "_");    // replace illegal CSS chars with underscore
                // add the new class name to the menu item so we can hide/style it with pure CSS
                YD.addClass(menuItems[i].id, newClassName.toLowerCase());
                
                // if this item itself is a sub-menu, then register for it's show event too
                var submenu = menuItems[i].cfg.getProperty("submenu");
                if (submenu)
                {
                    submenu.beforeShowEvent.subscribe(TagMenuItems);
                }
            }
            // no need to call this again everytime we show the menu
            this.beforeShowEvent.unsubscribe(TagMenuItems);
        } catch (e) {}        // catch any exceptions and ignore them - errors will just cause the styles not to get removed, but not affect any other scripts
    }
}
Step 2

Add the appropriate CSS to hide whatever menu items you want. This code adds a unique classname to every menu item and submenu item in the Share and Style menus. You can then use that classname in a CSS rule to hide whatever menu items you don't want to display. You can do this globally or combine it with any other CSS modifiers to only do it in a category, in a subcategory, in a gallery, etc...

The CSS to hide a menu item looks like this:

.share_get_a_link_menuitem {display:none;}

The name of the menu button comes first. Then, the name of the menu item that you want to hide is next, then the text menuitem is last. Any spaces or non-alpha numeric chars in the menu item are converted to underscores. It is always all lowercase regardless of what is in the menu.

To hide the StumbleUpon menu item in the Social Bookmarking submenu of the share button, you would use this:

.share_stumbleupon_menuitem {display:none;}

To hide the slideshow view from the Style menu, you would use this:

.style_slideshow_menuitem {display:none;}

To hide the slideshow view from the Style menu, but only when you are not logged in, you would use this:

.notLoggedIn .style_slideshow_menuitem {display:none;}

To hide the Buy All Digital Downloads menu item, you would add this:

.buy_all_digital_downloads_menuitem {display: none;}

And so on...

This customization is more flexible than the previous version here, so I would suggest using this new one instead.
__________________
--John
HomepagePopular
JFriend's javascript customizationsSecrets for getting fast answers on Dgrin
Always include a link to your site when posting a question

Last edited by jfriend; Feb-09-2011 at 09:16 AM.
Old Jan-21-2010, 04:06 AM
#2
Foques is offline Foques
He who caN
Foques's Avatar
great tool, but is there a way to hide the "Get a link" option from visitors, and keep it when I am logged in as the admin?

thank you.
Old Jan-21-2010, 05:41 AM
#3
jfriend is offline jfriend OP
Scripting dude-volunteer
Quote:
Originally Posted by Foques
great tool, but is there a way to hide the "Get a link" option from visitors, and keep it when I am logged in as the admin?

thank you.
After installing the script, use the CSS:

.notLoggedIn .share_get_a_link_menuitem {display:none;}
__________________
--John
HomepagePopular
JFriend's javascript customizationsSecrets for getting fast answers on Dgrin
Always include a link to your site when posting a question
Old Jan-21-2010, 08:25 AM
#4
Foques is offline Foques
He who caN
Foques's Avatar
not that its a big shock or anything, but it worked.

thank you very much!
Old Apr-05-2010, 12:12 PM
#5
ChancyRat is offline ChancyRat
Soooo Beginner Grinner
Adding "old journal" style back into the drop-down list?
Could this code be modified to add the Old Journal style back into the drop-down list? Thanks.
Old Apr-05-2010, 12:53 PM
#6
Allen is online now Allen
"tweak 'til it squeaks"
Allen's Avatar
Quote:
Originally Posted by ChancyRat
Could this code be modified to add the Old Journal style back into the drop-down list? Thanks.
I wish Smug would add it back. It is used many times and the new journal
style just doesn't do it for html type pages.
Old Apr-05-2010, 12:58 PM
#7
jfriend is offline jfriend OP
Scripting dude-volunteer
Quote:
Originally Posted by Allen
I wish Smug would add it back. It is used many times and the new journal
style just doesn't do it for html type pages.
But, if you are doing an HTML page, you just set it to journal (old) in gallery settings. You don't need it in the Style menu, do you?
__________________
--John
HomepagePopular
JFriend's javascript customizationsSecrets for getting fast answers on Dgrin
Always include a link to your site when posting a question
Old Apr-05-2010, 12:58 PM
#8
jfriend is offline jfriend OP
Scripting dude-volunteer
Quote:
Originally Posted by ChancyRat
Could this code be modified to add the Old Journal style back into the drop-down list? Thanks.
I don't know. Code would have to be written to try it.
__________________
--John
HomepagePopular
JFriend's javascript customizationsSecrets for getting fast answers on Dgrin
Always include a link to your site when posting a question
Old Apr-05-2010, 02:12 PM
#9
pillman is offline pillman
Ella
pillman's Avatar
Concerning this thread:

http://www.dgrin.com/showthread.php?t=163966

Would also like to have "get a Link" option when logged in ...Is that
possible with changes noted in above thread.
Bill
__________________
Bill Anderson Photography *
Favorites
WWJD
Old Apr-05-2010, 02:15 PM
#10
jfriend is offline jfriend OP
Scripting dude-volunteer
Quote:
Originally Posted by pillman
Concerning this thread:

http://www.dgrin.com/showthread.php?t=163966

Would also like to have "get a Link" option when logged in ...Is that
possible with changes noted in above thread.
Bill
The entire Share button can be hidden when not logged in and shown when logged in very easily. Just turn Easy Sharing on in the desired galleries and then add this CSS:

.notLoggedIn #shareButton {display:none;}
__________________
--John
HomepagePopular
JFriend's javascript customizationsSecrets for getting fast answers on Dgrin
Always include a link to your site when posting a question
Old Apr-05-2010, 03:34 PM
#11
pillman is offline pillman
Ella
pillman's Avatar
Thanks
__________________
Bill Anderson Photography *
Favorites
WWJD
Old Jun-28-2010, 10:26 AM
#12
CWSkopec is offline CWSkopec
Major grins
CWSkopec's Avatar
Can this code be used to hide items from the Buy menu?

I gave it a try as best I could, which was limited to adding the following to the CSS instead of something share or style menu related.

.buy_this_photo_menuitem {display:none;}

It doesn't appear to have worked and I'm clueless as to what would need to change in the java to make it work...?
Old Jun-28-2010, 10:39 AM
#13
jfriend is offline jfriend OP
Scripting dude-volunteer
Quote:
Originally Posted by CWSkopec View Post
Can this code be used to hide items from the Buy menu?

I gave it a try as best I could, which was limited to adding the following to the CSS instead of something share or style menu related.

.buy_this_photo_menuitem {display:none;}

It doesn't appear to have worked and I'm clueless as to what would need to change in the java to make it work...?
No. This code doesn't operate on the Buy menu. What exactly are you trying to accomplish? You can turn off print ordering for a specific gallery in gallery options.
__________________
--John
HomepagePopular
JFriend's javascript customizationsSecrets for getting fast answers on Dgrin
Always include a link to your site when posting a question
Old Jun-28-2010, 10:59 AM
#14
CWSkopec is offline CWSkopec
Major grins
CWSkopec's Avatar
Quote:
Originally Posted by jfriend View Post
No. This code doesn't operate on the Buy menu. What exactly are you trying to accomplish? You can turn off print ordering for a specific gallery in gallery options.
I've got my galleries set to the Thumbnail view because it's the most visually appealing to me and to keep things simplified for visitors I don't give them access to change the style (which can be debated good or bad, but at the moment it's how I prefer to present my photos). The problem, as minor as it is, the "This Photo" option is greyed out under the Buy menu. I've added a feature request to the Uservoice site to allow it and to have it trigger a drop down asking which photo similar to the share menu, but was hoping to remove it from the list in the meantime as it looks odd being there but not selectable.

Not a major problem, but if it was possible to take it out, I'd prefer it not there!
Old Jan-26-2011, 05:48 PM
#15
jfriend is offline jfriend OP
Scripting dude-volunteer
Tweaked this code slightly to work with the Buy menu too. The code in the first post will now work with the Buy menu, the Share menu and the Style menu. Items can be removed or formatted from any of those menus or their resulting sub-menus.
__________________
--John
HomepagePopular
JFriend's javascript customizationsSecrets for getting fast answers on Dgrin
Always include a link to your site when posting a question
Old Jan-26-2011, 05:59 PM
#16
Andy is offline Andy
panasonikon
Andy's Avatar
Quote:
Originally Posted by jfriend View Post
But, if you are doing an HTML page, you just set it to journal (old) in gallery settings. You don't need it in the Style menu, do you?
__________________
Andy
Moon River PhotographyWorkshopsGoogle+FacebookTwitter
Old Feb-07-2011, 11:34 AM
#17
MichaelLockhart is offline MichaelLockhart
Big grins
Hi,

I'm trying to hide the "Create a Card" item from the 'Buy' menu. I've created this CSS code:

.buy_create_a_card_menuitem {display: none;}

but it doesn't appear to be working. Any suggestions? The gallery I'm working from is http://www.michaellockhartphoto.com/Galleries/Waterfalls/15171536_d7dUv#1177472851_iJiDQ

Thanks!

Michael
__________________
Michael Lockhart Photography | Like me on Facebook and I'll like you too! | Don't forget to read my Blog | Follow me on Twitter!
Old Feb-07-2011, 12:16 PM
#18
jfriend is offline jfriend OP
Scripting dude-volunteer
Quote:
Originally Posted by MichaelLockhart View Post
Hi,

I'm trying to hide the "Create a Card" item from the 'Buy' menu. I've created this CSS code:

.buy_create_a_card_menuitem {display: none;}

but it doesn't appear to be working. Any suggestions? The gallery I'm working from is http://www.michaellockhartphoto.com/Galleries/Waterfalls/15171536_d7dUv#1177472851_iJiDQ

Thanks!

Michael
Because you've changed the text in the Buy menu and that script runs first, you would need this CSS:

.click_here_to_buy_create_a_card_menuitem {display: none;}
__________________
--John
HomepagePopular
JFriend's javascript customizationsSecrets for getting fast answers on Dgrin
Always include a link to your site when posting a question
Old Feb-07-2011, 01:09 PM
#19
MichaelLockhart is offline MichaelLockhart
Big grins
Ah, makes perfect sense. Thank you sir!

Michael
__________________
Michael Lockhart Photography | Like me on Facebook and I'll like you too! | Don't forget to read my Blog | Follow me on Twitter!
Old Feb-17-2011, 10:36 AM
#20
Claude203 is offline Claude203
Big grins
Claude203's Avatar
Quote:
Originally Posted by jfriend View Post
The entire Share button can be hidden when not logged in and shown when logged in very easily. Just turn Easy Sharing on in the desired galleries and then add this CSS:

.notLoggedIn #shareButton {display:none;}
Can the entire Share button be hidden when logged out as well as when logged in?

Thank you.
__________________
Claude

Claude Johnson
Black Fives Photo Archive
photos.blackfives.com
Page 1  of  3
1 2 3
Tell The World!  

Thread Tools
Display Modes

Posting Rules  
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump