WebSite X5Help Center

 
Sascha J.
Sascha J.
User

Login "Interface" has to be gone once you're logged in. How?  en

Author: Sascha J.
Visited 3497, Followers 2, Shared 0  

Hello everyone,

I've got an issue.

Is there a way, that the Login widget hides when you log in?

When you log-in the logout button becomes visible and I need that the login interface is gone once you're logged in.

If you logout the login interface needs to become visible again, is that possible? How?

Thanks!

Posted on the
17 ANSWERS - 4 USEFUL - 1 CORRECT
Paul M.
Paul M.
Moderator

Hello Sascha,

You could test for the login condition using PHP and then display or hide the login div conditionally, depending on the result.

To do this follow these steps:

1. Give all the pages in your project a file extension ending in .php by going to Step 2 Map Creation...  click once in each page in the sitemap to give it focus, then click the 'Properties' button on the right-hand side of the screen.  Go to the 'Expert' tab and select 'php' from the 'File Name Format' drop-down menu.  Repeat for every page in your project.

2. Add the following code in Step 4 Advanced Settings > Statistics, SEO and Code > Expert tab...  select 'Before closing the HTML tag' from the 'Custom Code' drop-down menu:

<?php

session_start();

require_once 'res/x5engine.php';

$pa = new imPrivateArea();
$user = $pa->who_is_logged();

if (!empty ($user)){ ;?>

<style type="text/css">#imLogin{

display:none !important;

}</style>

<?php } ?>

3. Delete all existing WebSite X5 files from your server.  Hold down the CTRL key and enter the Preview mode.  Allow the preview to build to completion by watching the progress bar in the bottom right of the screen.  Then upload ALL files to your server in Step 5, not just those recently modified.

Clear your browser cache and test.

Kind regards,

Paul

Read more
Posted on the from Paul M.
Sascha J.
Sascha J.
User
Author

Hello Paul,

this worked like a charm!

Thanks!!

The next problem I'm facing is, if I login or out it says:

Not Found

The requested URL /index.html was not found on this server.

How do I solve this simple issue?

Greetings,

Sascha.

Read more
Posted on the from Sascha J.
Sascha J.
Sascha J.
User
Author

Also if I click on my Shopping Cart I get a Blank White Page.

Test it yourself if you want.

http://www.saschajansen.com

ID: user

PW: user

Read more
Posted on the from Sascha J.
Sascha J.
Sascha J.
User
Author

Ok, the login works now with index.php but my Shopping Cart isn't working.

And when I'm logged in, the blue star icons on the Shop Drop down menu and the texts are disorted. How can I fix this?

Read more
Posted on the from Sascha J.
Paul M.
Paul M.
Moderator

The 'homepage URL' which a user returns to after logging out is stored as a variable in one of the X5 scripts.

Did you delete all the files from the server?  And then hold down the CTRL key whilst entering preview, etc.?  Doing so should have refreshed the redundant file on the server after you changed the homepage from index.html to index.php

However, don't worry  -  you can do the following to force a refresh on the file in question:

1.  In Step 1 General Settings > General tab, temporarily set the WebSite Address (URL) to a value anything other than that of your actual site

2.  Hold down the CTRL key and enter the Preview, etc.

3.  Go back to Step 1 General Settings > General tab, and set the WebSite Address (URL) to the correct, actual name of your website

4.  Hold down the CTRL key and enter the Preview, etc.

5.  Export ALL the project files to the server in Step 5

6.  Check for correct operation

Please let us know how you get on...  we are here to help if we can.

Read more
Posted on the from Paul M.
Paul M.
Paul M.
Moderator

Hmmm, I may need some more time to think this one through Sascha in order to come up with a more complete solution.  You can leave it with me if you like and I'll try to take a long hard look at the Shopping Cart issue when I have sufficient time, which unfortunately I don't have right now.

The Shopping Cart issue at first glance appears to be a result of changing to a .php file extension: however, the .php file extension is necessary to allow the conditional check on the page to discover whether or not the user is logged in.

This is what happens when customising...  you fix one thing and another breaks  

Is it absolutely essential to you to have a login widget in the header as opposed to a login page?

Read more
Posted on the from Paul M.
Sascha J.
Sascha J.
User
Author

Thanks Paul!

The index.php works now after I log-in.

I have an external login page, if you click on "Anmelden" on the right bottom of the header, it will lead you to the external login page.

I just had the Login Widget in the header enabled to test something, I will remove it.

But yeah the Shopping Cart issue, the disorted icons and text in my Drop Down Menu are my only issues right now.

I would be glad, if you would find a solution soon. I'll look into it myself too.

As you said, you fix one thing, another breaks, that's common.

Read more
Posted on the from Sascha J.
Sascha J.
Sascha J.
User
Author

Ok so, I deleted the php code (to make the Login Widget invisible) in Step 4 > SEO and Code > Expert and now my Shopping Cart, Icons and Texts in the Drop Down Menu are working fine.

But, do you see on my Website the header text "Anmelden" which leads to a login page?

I want it to change if you're logged in into "logout". How's that possible?

http://www.saschajansen.com

ID: user

PW: user

Thanks in advance.

Read more
Posted on the from Sascha J.
Paul M.
Paul M.
Moderator

I do see the header text you refer to, Sascha, and I understand what you would like to do, but it wouldn't be straightforward for exactly the same reasons as we've just discovered.

The only way to check if a user is logged in or otherwise is by testing via a PHP script, because WebSite X5 uses PHP for access management.  We've already found out that changing the .html file extensions to .php (without doing other modifications) will break certain aspects of WebSite X5.

There is a way of running PHP on pages with .html extensions but it might also break correct operation and is not guaranteed.  But if you want you can try it...  it involves adding a single line to your .htaccess file on your server:

AddType application/x-httpd-php .html

This would allow you to use the code I posted earlier whilst retaining the .html file extensions on pages like the Shopping Cart.

I am still thinking about your request (I enjoy stuff like that!) and if I come up with a more elegant solution then I will certainly get back to you.

Read more
Posted on the from Paul M.
Sascha J.
Sascha J.
User
Author

I understand Paul, well, I'll leave every site as .php. Since I deleted the code from above you gave me. Since then, my Shopping Cart seems to work properly.

Currently I'm trying to add this Code:

<?php

$pa = new imPrivateArea();

$user = $pa->who_is_logged();

echo $user['username'];

?>

I want it to show on every site that you're logged in as User "XY".

But I couldn't figure out, where to put this Code yet. Do you know where I have to put it?

I might try adding "AddType application/x-httpd-php .html" into the .htaccess file if it's necessary.

I appreaciate your time Paul, thanks!

Read more
Posted on the from Sascha J.
Paul M.
Paul M.
Moderator

Add the code in two parts, Sascha.  First go to Step 2 Map Creation and enter the 'Properties' of any page to which you wish to add this code.  Then go to the 'Expert' tab and select 'Before closing the HTML tag' from the 'Custom Code' drop-down menu.  Then paste the following code in:

<?php

session_start();

$pa = new imPrivateArea();

$user = $pa->who_is_logged();

?>

You'll then be able to use an HTML Code Object to display the username anywhere on that page, as follows:

You are logged in as <?php echo $user['username']; ?>

Hope that's clear enough, but if not let me know.

Read more
Posted on the from Paul M.
Sascha J.
Sascha J.
User
Author

Thanks Paul.

I followed your steps, now I'm getting a blank white page. It's the same issue we had before with the Shopping Cart. Hmm.

Read more
Posted on the from Sascha J.
Paul M.
Paul M.
Moderator

Did you do CTRL-preview, overwrite the files on the server, and flush the browser cache?

There shouldn't be any issues with that particular piece of code...  it's tried and tested.  I just checked it in a v12 test project to be sure and it worked first time.

Is there any other custom code on the page in question?  Can you post a link?  Thanks...

Read more
Posted on the from Paul M.
Sascha J.
Sascha J.
User
Author

Just to get this straight, with CTRL-Preview you mean holding CTRL and press Preview?

I deleted all server files, uploaded all files again and cleaned my browser cache.

I applied the code to the "Homepage" site, it just has a Gallery, HTML Object with this code:

<div align="center" width="100%" style="border-width: 1px 0 0 0; border-style:solid; border-color: gray; margin:5px 0 0 0; padding:0; height:0;" /></div>

and an E-Mail Newsletter form.

http://www.saschajansen.com/alle-produkte.php <- works, if you click on homepage you get a blank white page where I added the code.

Read more
Posted on the from Sascha J.
Paul M.
Paul M.
Moderator
Sascha J.
Just to get this straight, with CTRL-Preview you mean holding CTRL and press Preview?

Yes, that's right.  I think you've maybe worked on the site again since your last post as the Home page is now showing?

Read more
Posted on the from Paul M.
Sascha J.
Sascha J.
User
Author

Yes, I was working on it till my WebsiteX5 12 Pro. started bugging and I had to reload a backup. The Site is back up with the codes but it's still not working, I couldn't figure out what the problem may be.

http://www.saschajansen.com/alle-produkte.php <- works, if you click on homepage you get a blank white page where I added the code.

Codes added to both of these sites:

http://www.saschajansen.com/index.php

http://www.saschajansen.com/hardwachsoel.php

And both sites don't work..

I deleted all files and made a new Project. I tried it with the same codes but that didn't work either when I uploaded the files to my Server.

I just don't know what to try now to fix it.

But, I don't give up!!

Read more
Posted on the from Sascha J.
Sascha J.
Sascha J.
User
Author

"Add the code in two parts, Sascha.  First go to Step 2 Map Creation and enter the 'Properties' of any page to which you wish to add this code.  Then go to the 'Expert' tab and select 'Before closing the HTML tag' from the 'Custom Code' drop-down menu.  Then paste the following code in:

<?php

session_start();

$pa = new imPrivateArea();

$user = $pa->who_is_logged();

?>

You'll then be able to use an HTML Code Object to display the username anywhere on that page, as follows:

You are logged in as <?php echo $user['username']; ?>

Hope that's clear enough, but if not let me know." - Quote from Paul M.

Well, I tested the Code for "You're logged in as "XY"" on several templates but it didn't work on any of them.

I'll delete the code now from my Main Project but I still want to have this feature, sadly it doesn't work.

Has anyone a possible solution?

Read more
Posted on the from Sascha J.