Community @ The Turning Gate

Support community for TTG plugins and products.

NOTICE

The Turning Gate's Community has moved to a new home, at https://discourse.theturninggate.net.

This forum is now closed, and exists here as a read-only archive.

  • New user registrations are disabled.
  • Users cannot create new topics.
  • Users cannot reply to existing topics.

You are not logged in.

#1 2017-11-17 02:31:17

rod barbee
Moderator
From: Port Ludlow, WA USA
Registered: 2012-09-24
Posts: 17,830
Website

Add log-out buttons to Client Managed or password protected albums

To allow clients to log out of a Client Response Managed album, you can add a Logout button to your album template's copy area:

<a href="/backlight/client-response/?c=client&a=logout"><input type="button" value="Logout"></a>

If you're using album level password protection (normal albums and non-managed CR albums), try adding this

<a href="?logout"><input type="button" value="Logout"></a>

Rod 
Just a user with way too much time on his hands.
www.rodbarbee.com
ttg-tips.com, Backlight 2/3 test site

Offline

#2 2017-11-19 16:19:54

Matthew
Administrator
From: San Francisco, CA
Registered: 2012-09-24
Posts: 5,795
Website

Re: Add log-out buttons to Client Managed or password protected albums

Let's have more fun with this.

First, a caveat. As of Backlight version 1.2.3, CLIENT_RESPONSE_MANAGED is not defined, and so the conditions below will not apply. Following our next update -- which will probably be labeled as 1.2.3 Release 2 -- it will start to work. The code below should be safe to use, though, as having CLIENT_RESPONSE_MANAGED undefined will simply skip the logic.

That out of the way, this PHPlugins function will add a contextual Logout button. You can use this generally, with the following observable behavior:

1. If page or album is unprotected, does nothing.
2. If album is protected, adds a Logout button.
3. If album is client managed, adds a Logout button.

I'm using ttg_scripts as my PHPlugins location, and then using jQuery to move the button to the desired location on the page.

For the sake of example, I have two locations defined below. Number 1 adds the button to the menu; number 2 adds the button into the page body. You can delete whatever you're not using, or use the examples as a base to write your own button insertion.

function ttg_scripts($style, $path) { 

	$logoutURL = '';

	if (PASSWORD_ENABLED && LOGGED_IN) {
		$logoutURL = '?logout';
	} elseif (defined('CLIENT_RESPONSE_MANAGED') && CLIENT_RESPONSE_MANAGED) {
		$logoutURL = shortSiteURL().'backlight/client-response/?c=client&a=logout';
	}

	if ($logoutURL) { ?>
		<script>
			// 1. add a Logout button to the menu
			var logoutButton = '<li class="menu-item"><a href="<?php echo $logoutURL; ?>">Logout</a></li>';
			$('.menu').append(logoutButton);

			// 2. add a Logout button to the copy area
			var logoutButton = '<a href="<?php echo $logoutURL; ?>">Logout</a>';
			$('.the__copy > .content').prepend(logoutButton);
		</script>
	<?php }

	return false;
}

Matt

The Turning Gate, http://theturninggate.net

Offline

#3 2017-11-19 23:20:03

rod barbee
Moderator
From: Port Ludlow, WA USA
Registered: 2012-09-24
Posts: 17,830
Website

Re: Add log-out buttons to Client Managed or password protected albums

I knew that there was some logic you’d included for determining logged in status. But couldn’t remember where I’d seen it.


Rod 
Just a user with way too much time on his hands.
www.rodbarbee.com
ttg-tips.com, Backlight 2/3 test site

Offline

#4 2017-11-20 09:37:31

Matthew
Administrator
From: San Francisco, CA
Registered: 2012-09-24
Posts: 5,795
Website

Re: Add log-out buttons to Client Managed or password protected albums

rod barbee wrote:

I knew that there was some logic you’d included for determining logged in status. But couldn’t remember where I’d seen it.

There's a more generic example of using that logic in the PHPlugins sample, showing how to determine whether a gallery is private or public, and the user logged in or out.


Matt

The Turning Gate, http://theturninggate.net

Offline

Board footer

Powered by FluxBB