Using .sm-user-loggedin

beardedgitbeardedgit Registered Users Posts: 854 Major grins
edited February 5, 2014 in SmugMug Customization
I'm using the following code to make a couple of menu items show only when logged in:
.sm-page-widget-nav a[href$="/comments.mg?"],
.sm-page-widget-nav a[href$="/stats/"],
.sm-accordion-item.sm-nav-item-toplevel a[href$="/comments.mg?"],
.sm-accordion-item.sm-nav-item-toplevel a[href$="/stats/"] {
  display:none
}
.sm-user-loggedin .sm-page-widget-nav a[href$="/comments.mg?"],
.sm-user-loggedin .sm-page-widget-nav a[href$="/stats/"],
.sm-user-loggedin .sm-accordion-item.sm-nav-item-toplevel a[href$="/comments.mg?"],
.sm-user-loggedin .sm-accordion-item.sm-nav-item-toplevel a[href$="/stats/"] {
  display:inline
}
Site is http://beardedgit.smugmug.com/ (beware the animated .gifs!), here's what I see in the menu...

Logged out:
i-LPLNvDg.jpg


Logged in:
i-Nr7TQjP.jpg

I just want to be sure about what .sm-user-loggedin is doing - is it allowing only me to see the menu items when logged in, or is it allowing anyone logged in to see them?
Yippee ki-yay, footer-muckers!

Comments

  • denisegoldbergdenisegoldberg Administrators Posts: 14,373 moderator
    edited February 5, 2014
    If I am logged in to smug I see your stats and comments navbar entries. If I click on either of them I am taken to the specified page on my site.

    --- Denise
  • beardedgitbeardedgit Registered Users Posts: 854 Major grins
    edited February 5, 2014
    Thanks for the swift feedback, Denise.

    It's back to the drawing-board for me then - I was hoping that it would show the items only for me and only when I'm logged in, as I wanted to extend the idea to some future tinkerings that I'll want to keep out of the reach of others.

    Any pointers to the right code would be much appreciated.
    Yippee ki-yay, footer-muckers!
  • AllenAllen Registered Users Posts: 10,013 Major grins
    edited February 5, 2014
    Look at the body class. Might use .sm-user-owner

    <body id="yui_3_8_0_1_1391621230553_2273" class="sm-user-pro sm-user-loggedin sm-user-owner
    sm-page sm-page-node sm-page-node-3hGr6 sm-page-gallery sm-page-gallery-album" style="">
    Al - Just a volunteer here having fun
    My Website index | My Blog
  • AllenAllen Registered Users Posts: 10,013 Major grins
    edited February 5, 2014
    I think I have a few div's somewhere using .sm-user-loggedin so might have to look at them.

    I just found this. Had to change from .sm-user-loggedin to .sm-user-owner
    Using both hid the block to me logged in.
    Not sure if it will work because I can't see logged out.
    .noShow {
      display: none;
    }
    
    .sm-user-owner .noShow {
      display: block;
    }
    
    Al - Just a volunteer here having fun
    My Website index | My Blog
  • AllenAllen Registered Users Posts: 10,013 Major grins
    edited February 5, 2014
    If I am logged in to smug I see your stats and comments navbar entries. If I click on either of them I am taken to the specified page on my site.

    --- Denise
    Guess what? Viisiting your site I see the class name in your page body class.
    sm-user-owner is not there

    <body id="yui_3_8_0_1_1391623009279_137" class="sm-user-pro sm-user-loggedin sm-page
    sm-page-node sm-page-node-QQ7vv sm-page-home" style="">

    So this class name can not be used to hide things from the public (other Smug uses that are logged in).
    Al - Just a volunteer here having fun
    My Website index | My Blog
  • beardedgitbeardedgit Registered Users Posts: 854 Major grins
    edited February 5, 2014
    Allen wrote: »
    Look at the body class. Might use .sm-user-owner

    <body id="yui_3_8_0_1_1391621230553_2273" class="sm-user-pro sm-user-loggedin sm-user-owner
    sm-page sm-page-node sm-page-node-3hGr6 sm-page-gallery sm-page-gallery-album" style="">
    Cheers for that, Allen. Do you think there's any mileage in using both class-names? If so, how would I stuff them into the code that I posted in the OP? Just replace .sm-user-loggedin with .sm-user-loggedin .sm-user-owner, maybe? <img src="https://us.v-cdn.net/6029383/emoji/ne_nau.gif&quot; border="0" alt="" >
    Yippee ki-yay, footer-muckers!
  • AllenAllen Registered Users Posts: 10,013 Major grins
    edited February 5, 2014
    beardedgit wrote: »
    Cheers for that, Allen. Do you think there's any mileage in using both class-names? If so, how would I stuff them into the code that I posted in the OP? Just replace .sm-user-loggen-in with .sm-user-loggedin .sm-user-owner, maybe? ne_nau.gif
    I tried both and it did not work. Might try only .sm-user-owner

    I have not unveiled so can't look not logged in.
    Al - Just a volunteer here having fun
    My Website index | My Blog
  • beardedgitbeardedgit Registered Users Posts: 854 Major grins
    edited February 5, 2014
    Allen wrote: »
    I tried both and it did not work. Might try only .sm-user-owner

    OK, I've changed all of my instances of .sm-user-loggedin to .sm-user-owner and it looks OK to me.

    If you could check it out from your end I'd be much obliged.

    Sorry about the code-typo in my previous post :-(
    Yippee ki-yay, footer-muckers!
  • AllenAllen Registered Users Posts: 10,013 Major grins
    edited February 5, 2014
    beardedgit wrote: »
    OK, I've changed all of my instances of .sm-user-loggedin to .sm-user-owner and it looks OK to me.

    If you could check it out from your end I'd be much obliged.

    Sorry about the code-typo in my previous post :-(
    One thing I thought of is, does your site recognize you when not logged in as the site owner?

    If so you might have to use (long shot)
    .sm-user-owner.sm-user-loggedin
    with no space
    adding space it doesn't work, tried it

    BTW, I do not see the menu items
    Al - Just a volunteer here having fun
    My Website index | My Blog
  • beardedgitbeardedgit Registered Users Posts: 854 Major grins
    edited February 5, 2014
    Allen wrote: »
    One thing I thought of is, does your site recognize you when not logged in as the site owner?
    Well, now that I've changed the code to .sm-user-owner the menu items show for me when I'm logged in and hide when I'm logged out, so I'd say no, it doesn't recognise me when I'm logged out.
    Yippee ki-yay, footer-muckers!
  • beardedgitbeardedgit Registered Users Posts: 854 Major grins
    edited February 5, 2014
    Allen wrote: »
    BTW, I do not see the menu items
    Looks like you've sussed it then!
    Thanks for the help, folks thumb.gif
    Yippee ki-yay, footer-muckers!
  • AllenAllen Registered Users Posts: 10,013 Major grins
    edited February 5, 2014
    beardedgit wrote: »
    Well, now that I've changed the code to .sm-user-owner the menu items show for me when I'm logged in and hide when I'm logged out, so I'd say no, it doesn't recognise me when I'm logged out.
    Great! guess we found the solution.
    Al - Just a volunteer here having fun
    My Website index | My Blog
  • beardedgitbeardedgit Registered Users Posts: 854 Major grins
    edited February 5, 2014
    Just a thought... now that this thread has been moved to the "New SmugMug Customization" Forum you might want to prefix the thread title with [Warning],[Heads up],[Here be Dragons!] or something like that as per your suggestion in http://dgrin.com/showthread.php?t=245004
    Yippee ki-yay, footer-muckers!
  • beardedgitbeardedgit Registered Users Posts: 854 Major grins
    edited February 5, 2014
    Revised code, FWIW:
    /* "Stats" and "Comments" menu links: hidden from all when logged out, show only to me when logged in */
    .sm-page-widget-nav a[href$="/comments.mg?"],
    .sm-page-widget-nav a[href$="/stats/"],
    .sm-accordion-item.sm-nav-item-toplevel a[href$="/comments.mg?"],
    .sm-accordion-item.sm-nav-item-toplevel a[href$="/stats/"] {
      display:none
    }
    .sm-user-owner .sm-page-widget-nav a[href$="/comments.mg?"],
    .sm-user-owner .sm-page-widget-nav a[href$="/stats/"],
    .sm-user-owner .sm-accordion-item.sm-nav-item-toplevel a[href$="/comments.mg?"],
    .sm-user-owner .sm-accordion-item.sm-nav-item-toplevel a[href$="/stats/"] {
      display:inline
    }
    
    Yippee ki-yay, footer-muckers!
Sign In or Register to comment.