Page 1 of 1
[SOLVED]Display different HTML Module when logged in
Posted: Sun Jun 15, 2025 7:46 am
by lockiedownunder
At the moments I have a Welcome html module displayed in my home page.
How can I display a different html module like WelcomeBack when user is logged it?
Or even further display html subject to Customer Group
Re: Display different HTML Module when logged in
Posted: Sun Jun 15, 2025 8:14 am
by by mona
We don’t know the module you have, if it uses twig, the controller or JavaScript, but off the top of my head you could do a simple modification in the twig by using
Code: Select all
{% if logged %}{{ text_return}}{% else %}{{text_welcome}}{% endif %}
an example of which is in catalog/view/default/template/common/header.twig for the account menu. Adding the text into the language file (required if you have languages).
For names it will be a bit more complicated but it is something that used to be requested quite often for OC1 so if you check the marketplace you might find something free that you can use as an example. This pretty much covers it
viewtopic.php?t=7222&start=40
Note $this-> is no longer used it is just $data - but all you have to do is look at the current file for the same page and convert it to the same format.
Same with
which is now as written above. You can also find php to twig converters online.
Not very complicated and worth trying yourself.
For more personalised or customer groups it will be much more complicated and require a full module.
Re: Display different HTML Module when logged in
Posted: Sun Jun 15, 2025 10:25 am
by lockiedownunder
It is just the standard html content module that comes with OC
Re: Display different HTML Module when logged in
Posted: Sun Jun 15, 2025 10:29 am
by lockiedownunder
Hopefully this helps to figure out the module again it comes with OC
Then assign it to home layout
Re: Display different HTML Module when logged in
Posted: Sun Jun 15, 2025 1:07 pm
by by mona
Nope the html module wont help you with this. You need a modification - something like the attached.
Re: Display different HTML Module when logged in
Posted: Sun Jun 15, 2025 11:24 pm
by Ethan1
You can use OpenCart’s built-in customer group and login status checks in your module's controller or custom layout. Just wrap your HTML in a PHP check like:
php
Copy
Edit
<?php if ($this->customer->isLogged()) { ?>
<!-- WelcomeBack HTML -->
<?php } else { ?>
<!-- Welcome HTML -->
<?php } ?>
For customer groups, use $this->customer->getGroupId() to show content based on group.
Re: Display different HTML Module when logged in
Posted: Mon Jun 16, 2025 12:12 pm
by halfhope
Hi!
You may use my extension "Extended Layout" to manage it.
Re: Display different HTML Module when logged in
Posted: Mon Jun 16, 2025 3:28 pm
by lockiedownunder
halfhope you are brilliant THANK YOU.
Re: [SOLVED]Display different HTML Module when logged in
Posted: Mon Jun 16, 2025 4:58 pm
by by mona