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 2018-11-20 19:39:23

Pete_N
Member
From: Hunter Valley, NSW, Australia
Registered: 2018-11-06
Posts: 20

Client logout of CRG (need BL2 code)

Good [after] morning Backligh2ers,

I'm beginning to set up the CRG feature in BL2 and have discovered that there should be an ability for a client to log out of his/her CRG session.

I found this post where Rod put forward an idea to do this in BL:
http://community.theturninggate.net/vie … hp?id=8228

I am unable to make the menu item appear in my Pangolin based BL2 CRG page.

May I please have the code, relevant to BL2 (or any similar versions that may have been written since)

Thanks kindly,

Pete.

Offline

#2 2018-11-20 21:12:36

Ben
Moderator
From: Melbourne, Australia
Registered: 2012-09-29
Posts: 4,399

Re: Client logout of CRG (need BL2 code)

Hi Pete, the logout link for BL2 should point to http://yoursite.com/backlight/clients/logout/  (replacing yoursite.com with your actual site URL).

Offline

#3 2018-11-20 21:30:48

Pete_N
Member
From: Hunter Valley, NSW, Australia
Registered: 2018-11-06
Posts: 20

Re: Client logout of CRG (need BL2 code)

G'day Ben,
So... It should look like this?:

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'*/
        $logoutURL = shortSiteURL().'backlight/clients/?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;
}

//No more after this line


Yes? (original code commented out for comparison.

Pete.

Offline

#4 2018-11-20 21:52:48

Pete_N
Member
From: Hunter Valley, NSW, Australia
Registered: 2018-11-06
Posts: 20

Re: Client logout of CRG (need BL2 code)

OK... I tested that code as I presented it.

On clicking the 'logout' button that appeared in the copy area, It took me to a login screen with blank email and password text fields in one instance... a second attempt at the same operation resulted in me being taken to a page (mysite/backlight/clients/albums) which told me what albums were assigned to me - It lists the album and its status as 'open for viewing'. Clicking on the album's tile returned me to the album again; clicking on the 'log ou' button resulted in a successful logout.

I prefer the second - if it is possible for one client to have access to more than one album.

Thanks,

Pete.

Offline

#5 2018-11-20 22:57:15

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

Re: Client logout of CRG (need BL2 code)

You’re using the wrong syntax for Backlight 2 phplugins.
See: http://community.theturninggate.net/vie … hp?id=8966

First. Make sure you start with a phplugins file that came with Backlight 2 (not from a previous version of Backlight or the TTG Lightroom plug-ins)

Secondlly the hooks are different and no longer heed an argument.

Use:

function ttg_scripts() {

....your code....

}

Instead




But a simpler solution might be to simply add a menu item using the URL Ben gave you to the menu set used for your Client Response Page template and add a button in the page template's copy area.

You would need a separate page template for you’re CR album templates and assign the menu set containing the logout link. The link would always be there, but if you’re using a Client Managed albums, that really doesn’t matter.


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

Offline

#6 2018-11-20 23:19:05

Pete_N
Member
From: Hunter Valley, NSW, Australia
Registered: 2018-11-06
Posts: 20

Re: Client logout of CRG (need BL2 code)

G'day Ben,

I made an error... I already had a line of code in the body of the album template:
<a href="/backlight/client-response/?c=client&a=logout"><input type="button" value="Logout"></a>
This worked correctly, without any of the above code in my customised php file.

I removed that line of code from the album template and tested the code in my custom PHP file as presented two posts above this. There was no effect with any of the three lines (each line was commented out and the other activated for the three tests:

/*the first test performed with only this line active: */
$logoutURL = shortSiteURL().'backlight/client-response/?c=client&a=logout'*/
/* the second test performed with only this line active:*/
$logoutURL = shortSiteURL().'backlight/clients/?c=client&a=logout'
/*the second test performed with only this line active:*/
$logoutURL = shortSiteURL().'http://mysite.com/backlight/clients/logout/'

Thanks Ben,

Pete

Offline

#7 2018-11-20 23:43:37

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

Re: Client logout of CRG (need BL2 code)

did you change the code syntax to conform with Backlight 2's requirements?


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

Offline

#8 2018-11-21 12:29:34

Pete_N
Member
From: Hunter Valley, NSW, Australia
Registered: 2018-11-06
Posts: 20

Re: Client logout of CRG (need BL2 code)

Good (after) morning Rod,

Ah... I need to do that here too? Ok, I'll change the syntax as soon as I get home.

Thanks kindly,
Pete

Offline

#9 2018-11-21 14:16:45

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

Re: Client logout of CRG (need BL2 code)

Hi Pete,

In the sample PHPlugins file for pangolin, included in the /backlight/custom/phplugins folder of your installation, you will find this sample function:

function main_top() { 
	echo '<ul style="background-color:#FFF9C4;color:#000;margin:1.5rem 0;padding:24px 36px;">';
		if (PASSWORD_ENABLED) {
			echo '<li><strong>This gallery is private</strong>.</li>';
			if (LOGGED_IN) {
				echo '<li><small>The user is logged in</small>.</li>';
			} else {
				echo '<li><small>The user is logged out</small>.</li>';
			}
		} elseif ( $this->isManaged() ) {
			echo '<li><strong>This gallery is client managed</strong>.</li>';
		} else {
			echo '<li><strong>This gallery is public</strong>.</li>';
		}
	echo '</ul>';
	return false;
} // END /**/

This is the most up-to-date syntax, and demonstrated how to use the logged-in/out conditions. You'd want to use this logic to display the logout button, and perhaps change the "main_top()" location to reflect the location at which you'd like the code to appear.


Matt

The Turning Gate, http://theturninggate.net

Offline

#10 2018-11-21 14:40:18

Pete_N
Member
From: Hunter Valley, NSW, Australia
Registered: 2018-11-06
Posts: 20

Re: Client logout of CRG (need BL2 code)

Ah... Good afternoon Matthew, We meet again. (I was the chap who started out with CE3 back in October 2013)
Thanks kindly for your assistance. I'm going to implement it now and see what it does.

I'm really not very good at all this. I'm slowly learning about HTML and CSS, although I'm certain that writing an HTML page with an accompanying CSS is quite different from working with a website engine like CE3 or BL2.

I shall persevere.

Thanks kindly.

Pete.

Offline

#11 2018-11-23 22:37:34

Pete_N
Member
From: Hunter Valley, NSW, Australia
Registered: 2018-11-06
Posts: 20

Re: Client logout of CRG (need BL2 code)

OK... I've stayed with the a line of code in the body of the album template:
<a href="/backlight/client-response/?c=client&a=logout"><input type="button" value="Logout"></a>
This worked correctly, without any of the above code in my customised php file.

As I begin to understand the way code is written and learn the names of all the php plugin hooks on the page, I'll look at placing more information where clients can see it: up in the top pallet.

For now - it is sufficient to operate.

On to more important matters!

Thanks Ben, Rod and Matt.

Pete

Offline

Board footer

Powered by FluxBB