Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#61 2012-08-22 12:52:34

CeBe
Plugin Author
From: Caen - Fr
Registered: 2010-06-25
Posts: 345
Website

Re: cbe_frontauth: Connect to (and disconnect from) backend from frontend

I found a little typo in the documentation while verfying if the plugin still works with TXP 4.5-beta.
Good news : it does.
Therefore, v0.9.3 is out :)

Offline

#62 2012-08-27 07:08:02

aslsw66
Member
From: Canberra, Australia
Registered: 2004-08-04
Posts: 342
Website

Re: cbe_frontauth: Connect to (and disconnect from) backend from frontend

After a lot of thought, I’ve finally decided to retrofit my site with cbe_frontauth instead of ign_password_protect.

A minor issue first. It seems like you can’t pass in a class to the default login form. I’ve figured out how modify the plugin to allow for this, but just thought that I would pass it on (unless I’m missing something of course).

My major issue is the same as Dragondz had earlier. When I click the logout link, it still shows me as logged in – I need to refresh the page again to get it to work properly. I did read Claire’s comment about redirects, but I’m struggling to get that to work. Here’s what I have so far. [EDIT] I fixed this by redirecting to “index.php” on logout. Seems to work so ar.

Finally, it’s a bit weird that this works across browsers. I’m testing my front-end in IE and modifying the back-end in Firefox. But if I log out in IE then I’m also logged out in FF as well!

Last edited by aslsw66 (2012-08-27 07:09:34)

Offline

#63 2012-08-27 08:02:35

CeBe
Plugin Author
From: Caen - Fr
Registered: 2010-06-25
Posts: 345
Website

Re: cbe_frontauth: Connect to (and disconnect from) backend from frontend

aslsw66 a écrit:

After a lot of thought, I’ve finally decided to retrofit my site with cbe_frontauth instead of ign_password_protect.

Great decision :D

It seems like you can’t pass in a class to the default login form.

Yes, you can, but you also have to use a wraptag :

<txp:cbe_frontauth_box wraptag="div" class="log-box" />

Finally, it’s a bit weird that this works across browsers. I’m testing my front-end in IE and modifying the back-end in Firefox. But if I log out in IE then I’m also logged out in FF as well!

It’s the default behaviour across all admin-side : just try with the standard Textpattern login, it will work the same manner. When you login with a second browser, it breaks the connection in the first one.

Offline

#64 2012-08-27 11:43:39

aslsw66
Member
From: Canberra, Australia
Registered: 2004-08-04
Posts: 342
Website

Re: cbe_frontauth: Connect to (and disconnect from) backend from frontend

Thanks for the response.

Is it possible to add a class for both the outer <div> and the <form> itself? I’m also trying to rework the site to use Twitter’s Bootstrap, and it uses a number of classes to provide the nice visual effects?

Also, what is best practice for developing? Ideally, I want to be in the back-end designing, and then testing the effects at the front-end.

Offline

#65 2012-09-28 17:37:49

zero
Member
From: Lancashire
Registered: 2004-04-19
Posts: 1,470
Website

Re: cbe_frontauth: Connect to (and disconnect from) backend from frontend

Help! I’m hopelessly confused, as usual, with anything slightly not straightforward with ifs and elses so if someone could explain the logic I need, I would be most grateful! I’ve tried for years and still cannot understand the logic behind many if and else things. I’ve tried books but it is still as clear as mud. TXP Genii, I know you can help!

I have a custom field, secure, which is usually empty. To protect an article a number relating to user permission is put in the field, eg 5 or 6, and only logged in users with privilege level of 5 or 6 or 1 are allowed to view the article. If there is nothing in the custom field, everybody can view it. I’ve tried many things and here is my latest attempt which does not work (it just shows the login form on unprotected articles or no content at all for protected ones):

<txp:if_custom_field name="secure">
  <txp:cbe_frontauth_if_logged>
    <txp:cbe_frontauth_protect level="1,'<txp:custom_field name="secure" />'">
Protected content
    </txp:cbe_frontauth_protect>
  </txp:cbe_frontauth_if_logged>
        <txp:else />
   	<txp:output_form form="form_login" />
</txp:if_custom_field>

As I say, if you could explain how to make it work, it would help enormously. I should understand this stuff, but I’m afraid I just don’t.


BB6 Band My band
Gud One My blog

Offline

#66 2012-09-28 17:44:21

CeBe
Plugin Author
From: Caen - Fr
Registered: 2010-06-25
Posts: 345
Website

Re: cbe_frontauth: Connect to (and disconnect from) backend from frontend

Yes, the if...else logic is

<txp:if_something>
  then instructions if "something" is true
<txp:else />
  "something" is wrong :)
</txp:if_something>

So, your code should be

<txp:if_custom_field name="secure">
  <txp:cbe_frontauth_if_logged>
    <txp:cbe_frontauth_protect level='1,<txp:custom_field name="secure" />'>
      Protected content
    </txp:cbe_frontauth_protect>
  <txp:else />
    <txp:output_form form="form_login" />
  </txp:cbe_frontauth_if_logged>
</txp:if_custom_field>

Last edited by CeBe (2012-09-28 19:16:23)

Offline

#67 2012-09-28 18:35:37

zero
Member
From: Lancashire
Registered: 2004-04-19
Posts: 1,470
Website

Re: cbe_frontauth: Connect to (and disconnect from) backend from frontend

Thanks Claire, but this still doesn’t work properly. There is something wrong with ,'<txp:custom_field name="secure" />' so I removed that for now. However, although it now works with level=1 (publisher) on the protected page, all unprotected pages have blank content. I want to be able to say “If there is nothing in the ‘secure’ custom field, display content as normal” but haven’t found a way to do that although I’ve juggled <txp:if_custom_field name="secure" value=""> around a bit, but without success.


BB6 Band My band
Gud One My blog

Offline

#68 2012-09-28 19:20:51

CeBe
Plugin Author
From: Caen - Fr
Registered: 2010-06-25
Posts: 345
Website

Re: cbe_frontauth: Connect to (and disconnect from) backend from frontend

Sorry… although I read and reread, I missed the syntax for <txp:cbe_frontauth_protect level='1,<txp:custom_field name="secure" />'> (now correct in the code above). Single quotes are around the entire expression, and not only the enclosed tag.

Offline

#69 2012-09-28 19:30:12

zero
Member
From: Lancashire
Registered: 2004-04-19
Posts: 1,470
Website

Re: cbe_frontauth: Connect to (and disconnect from) backend from frontend

Ah yes, the entire expression. Thanks Claire.


BB6 Band My band
Gud One My blog

Offline

#70 2012-09-28 19:32:20

hilaryaq
Plugin Author
Registered: 2006-08-20
Posts: 335
Website

Re: cbe_frontauth: Connect to (and disconnect from) backend from frontend

How about:

<txp:cbe_frontauth_if_logged>
    <txp:cbe_frontauth_protect level="1'<txp:if_custom_field name="secure">,<txp:custom_field name="secure" /><txp:else /></txp:if_custom_field>'">
Protected content
    </txp:cbe_frontauth_protect>
  </txp:cbe_frontauth_if_logged>
        <txp:else />
   	<txp:output_form form="form_login" />

Or some such.. it’s more the logic than anything I think!


…………………
I <3 txp
…………………

Offline

#71 2012-09-28 21:44:28

zero
Member
From: Lancashire
Registered: 2004-04-19
Posts: 1,470
Website

Re: cbe_frontauth: Connect to (and disconnect from) backend from frontend

Yes, it’s definitely the logic, Hilary! I think I’ve got it and I think I even understand its logic too :-)

<txp:if_custom_field name="secure"> // (There is always this custom field even if empty)
  <txp:cbe_frontauth_protect level='1,<txp:custom_field name="secure" />'>
    <txp:cbe_frontauth_if_logged> 
        Protected content just for the privileged few
    </txp:cbe_frontauth_if_logged> 
          <txp:else /> // If they are not logged in or have wrong privilege level	 
            <txp:output_form form=“form_login” /> // Show login form
   </txp:cbe_frontauth_protect> 
</txp:if_custom_field>
  <txp:if_custom_field name="secure" value=""> If field is empty/article is unprotected
              Unprotected content whether logged in or not
  </txp:if_custom_field>

Thanks for the help. I hope this perhaps helps other code-phobics!


BB6 Band My band
Gud One My blog

Offline

#72 2012-09-28 21:53:36

hilaryaq
Plugin Author
Registered: 2006-08-20
Posts: 335
Website

Re: cbe_frontauth: Connect to (and disconnect from) backend from frontend

Glad you got it working, well done!! Once the logic clicks you can do anything with txp :)


…………………
I <3 txp
…………………

Offline

Board footer

Powered by FluxBB