Post by lockiedownunder » Sun Jun 15, 2025 7:46 am

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
Last edited by lockiedownunder on Mon Jun 16, 2025 3:29 pm, edited 1 time in total.

OC 3.0.4.1
PHP 8.2
Keep Smiling ;D


New member

Posts

Joined
Sun Nov 01, 2015 3:00 pm


Post by by mona » Sun Jun 15, 2025 8:14 am

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

Code: Select all

 <?php if (!$logged) { ?>
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.

DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


https://www.youtube.com/watch?v=zXIxDoCRc84


User avatar
Expert Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by lockiedownunder » Sun Jun 15, 2025 10:25 am

It is just the standard html content module that comes with OC

OC 3.0.4.1
PHP 8.2
Keep Smiling ;D


New member

Posts

Joined
Sun Nov 01, 2015 3:00 pm


Post by lockiedownunder » Sun Jun 15, 2025 10:29 am

Hopefully this helps to figure out the module again it comes with OC
Then assign it to home layout

Attachments

???
Screenshot 2025-06-15 122726.jpg
Screenshot 2025-06-15 122630.jpg

Screenshot 2025-06-15 122630.jpg (15.7 KiB) Viewed 593 times


OC 3.0.4.1
PHP 8.2
Keep Smiling ;D


New member

Posts

Joined
Sun Nov 01, 2015 3:00 pm


Post by by mona » Sun Jun 15, 2025 1:07 pm

Nope the html module wont help you with this. You need a modification - something like the attached.
Last edited by by mona on Mon Jun 16, 2025 4:45 pm, edited 2 times in total.

DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


https://www.youtube.com/watch?v=zXIxDoCRc84


User avatar
Expert Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by Ethan1 » Sun Jun 15, 2025 11:24 pm

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.

Newbie

Posts

Joined
Sun Jun 15, 2025 11:01 pm

Post by halfhope » Mon Jun 16, 2025 12:12 pm

Hi!

You may use my extension "Extended Layout" to manage it.

My FREE extensions in marketplace. [ security | flexibility | speedup ]


User avatar
Active Member

Posts

Joined
Tue Dec 10, 2013 9:44 pm
Location - San Diego

Post by lockiedownunder » Mon Jun 16, 2025 3:28 pm

halfhope you are brilliant THANK YOU.

OC 3.0.4.1
PHP 8.2
Keep Smiling ;D


New member

Posts

Joined
Sun Nov 01, 2015 3:00 pm


Post by by mona » Mon Jun 16, 2025 4:58 pm

Yes much better solution
https://www.opencart.com/index.php?rout ... r=halfhope

Thank you halfhope

DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


https://www.youtube.com/watch?v=zXIxDoCRc84


User avatar
Expert Member

Posts

Joined
Mon Jun 10, 2019 9:31 am
Who is online

Users browsing this forum: Amazon [Bot] and 45 guests