Title might be a bit confusing, so let me explain.
I have a website that has a side-panel, which contains information about the user, things the user can do, etc. When the user is not logged in, this side-panel becomes the area for logging in or registration.
The code for this is:
<?php if($user->loggedIn) { ?> <!-- side-panel for logged in users here --> <?php } else { ?> <!-- login/registration etc --> <?php } ?>
What I want to do is load this snippet of code again when the user clicks login with AJAX, and use a jQuery effect (probably fade) that smoothly makes the side-panel transition from login/registration to the shiny users-only panel.
I know I could do this if I put that code in another file, and loaded it through AJAX into the div for the side-panel… but I would rather not make a separate file for the side-panel only. Is this possible?
You could load the page with an AJAX request and then strip out the data other than the side panel, but what would be the point? Your best option would be to simply separate the side panel into its own file.
Oh, and that would also be considered the proper way of doing it, so you can edit the sidebar without editing the pages it occurs on.