Camen Design Forum

Delete

(Leave this as-is, it’s a trap!)

To delete this post you must be either the original author or a designated moderator.
The content of the post will be removed but the name and date will remain.

  • The post will be removed completely from the thread, rather than blanked
  • Only posts on the last page of the thread can be removed completely (so as to not break permalinks)

RE[3]: How to display more menu for logged in user?

Kroc

Thanks for the description @Martijn; NNF tries to avoid sessions and cookies and storing this kind of infinite-growth data on the server. The sign-in link uses HTTP_AUTH, a feature provided by browsers to prepend the username/password to every request. There is no way to sign-out however other than closing the browser or clearing the cache! The browser is managing this, I have no control over it!

Once signed in however, every request has the username/password included, so you can easily identify the user the same as if they used the user/pw field. The constant AUTH is set to true if the user has provided a correct un/pw and additionally AUTH_HTTP is set to true if they are 'signed in'.

DOMTemplate works on *removing* elements from the template that aren't needed. Therefore, if you want to add a menu for logged-in users, just add the menu HTML to the template file (/themes/greyscale/*.html) and remove the element if the user is not logged in.

You're correct that you just need to add your menu's ID to that list of element-IDs that get removed from the page if the user is *not* signed in :)

:: @Kroc added on 08 Aug ’23 · 09:01

Correction! There appears to be a bug there maybe because that entire chain of DOMTemplate commands is predicated by CAN_POST, a set of conditions based on factors other than signed in status

% php
if (CAN_POST) $template->set (array ( 
    ....
//is the user already signed-in?
))->remove (AUTH_HTTP
%

Therefore you probably want to add your own DOMTemplate call just for your menu, like this:

% php
if (!HTTP_AUTH) $template->remove ( '#menu-id' );
%

Your friendly neighbourhood moderators: Kroc, Impressed, Martijn