Show/Hide link in navbar based on userID value

Hi,
I cannot find a way to show/hide ‘log out’ in the nav bar of my _header include file based on the userID (logged in: id>0 / out: id<1). I defined a Security Identity in the Globals so i could access it from anywhere. How can I access my global security identity from the properties panel of the navbar / of the ‘log out’ link?
Thanks

Please check the Defining Global Steps here:

Thanks,
I did setup my globals as per this guide but the Identity step does not appear in the data binding options of the dynamic attributes for the logout link of my nav bar.

It should be appearing on the top of the data picker. What do you see in the data picker on the page exactly?

Shall I create a variable in the globals maybe and assign the userid value to it?

FYI

So is this some SSI include or is it a content page where you don’t see the global steps in the data picker?

It is the content of the header page, from which I create SSI for the other pages’ headers.
I see the global identity in the datapicker of DB update. But that’s server side. I want to access that value from the server connect side too.


I’ve followed the simple steps shown by Ken (select Globals, right click on Steps, Secu Provider/Secu identity…)

Ah yes i understand now.
In order to access the global steps on the page, you need a server action added to it.
You can just create some userInfo server action which just gets the user details by filtering a query (or even just an empty one) and add it to your SSI include in App Structure. This will bring the identity step in the data picker, so you can use it with the dynamic attributes on the page.

Ok I’ve added the API action with a single DB id query (screenshot), but I don’t understand this step:

Sorry I was not clear. I’m tweaking my SSI header.php file in order to create the show/hide function, which will replicate to all pages with the same navbar.

You have two options:

  • Create an API Action, which contains an database query filtered by the identify step. This way you will have access to users details.
  • Create an empty API action. This way you will have access to user identity only.

Then, in your SSI include, in App Structure click App, click the Add New button, select Data > Server Connect and select your server action.
This will include your server action and it will load with your SSI include.

Then in the data picker, you will be able to pick the identity for show/hide attributes or any other dynamic attributes in your SSI:

1 Like

Alright! I didn’t know this trick! An empty API action returns the user ID by default :+1:

I can do my show condition now, THANKS!
image

1 Like