Load different template for logged in users in the frontend

Need help with the Administration of your Joomla! 5.x site? This is the spot for you.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10
Post Reply
deeno
Joomla! Intern
Joomla! Intern
Posts: 65
Joined: Fri Nov 03, 2006 1:07 pm

Load different template for logged in users in the frontend

Post by deeno » Tue Apr 23, 2024 7:22 am

Dear all,

is it possible to achieve the following:
A different template should be loaded for logged in users in the frontend.

I got an answer, that this is Joomla core functionality and I should assign the template just for guests to the guest access level...
But unfortunately I can't find any info/how-to online, nor can I see an option for this in the actual clean J!5.1 installation... Am I missing something, or is this just not possible?

Any hint/help greatly appreciated!

All best,
Dino

gws
Joomla! Champion
Joomla! Champion
Posts: 5970
Joined: Tue Aug 23, 2005 1:56 pm
Location: South coast, UK
Contact:

Re: Load different template for logged in users in the frontend

Post by gws » Tue Apr 23, 2024 10:46 am

You can assign templates in the menu item for that page.

deeno
Joomla! Intern
Joomla! Intern
Posts: 65
Joined: Fri Nov 03, 2006 1:07 pm

Re: Load different template for logged in users in the frontend

Post by deeno » Tue Apr 23, 2024 11:39 am

Thanks for the answer.
But how would this allow a logged in user to see a different template for the whole website (all menus)?
How does this combine with the suggestion to use guest access levels?

gws
Joomla! Champion
Joomla! Champion
Posts: 5970
Joined: Tue Aug 23, 2005 1:56 pm
Location: South coast, UK
Contact:

Re: Load different template for logged in users in the frontend

Post by gws » Tue Apr 23, 2024 11:41 am

Make the logged in template the default and then use a different template for the non logged in pages.

deeno
Joomla! Intern
Joomla! Intern
Posts: 65
Joined: Fri Nov 03, 2006 1:07 pm

Re: Load different template for logged in users in the frontend

Post by deeno » Tue Apr 23, 2024 11:48 am

Are you implying to manually assign it to each page? Or is there a central place to set it up once?

gws
Joomla! Champion
Joomla! Champion
Posts: 5970
Joined: Tue Aug 23, 2005 1:56 pm
Location: South coast, UK
Contact:

Re: Load different template for logged in users in the frontend

Post by gws » Tue Apr 23, 2024 12:00 pm

You can set it globally in Template/styles.

deeno
Joomla! Intern
Joomla! Intern
Posts: 65
Joined: Fri Nov 03, 2006 1:07 pm

Re: Load different template for logged in users in the frontend

Post by deeno » Tue Apr 23, 2024 12:05 pm

I must be blind, I tried every backend setting in J!5.1, cannot find it. Would you mind sharing a screenshot please? Thank you so much!

gws
Joomla! Champion
Joomla! Champion
Posts: 5970
Joined: Tue Aug 23, 2005 1:56 pm
Location: South coast, UK
Contact:

Re: Load different template for logged in users in the frontend

Post by gws » Tue Apr 23, 2024 12:14 pm

screendump.jpg
You do not have the required permissions to view the files attached to this post.

deeno
Joomla! Intern
Joomla! Intern
Posts: 65
Joined: Fri Nov 03, 2006 1:07 pm

Re: Load different template for logged in users in the frontend

Post by deeno » Tue Apr 23, 2024 1:21 pm

Thank you for the screenshot. I think there is a misunderstanding. I know how to set a default template/style, but how does this allow me (or joomla) to distinguish if a visitor has been logged in in the joomla frontend, in order to feed him/render the different template?

gws
Joomla! Champion
Joomla! Champion
Posts: 5970
Joined: Tue Aug 23, 2005 1:56 pm
Location: South coast, UK
Contact:

Re: Load different template for logged in users in the frontend

Post by gws » Tue Apr 23, 2024 1:34 pm

As I said earlier use the menu options.On pages for general public use template public on registered pages menus that point to registered pages use template registered. If your site is large and you have too many menu items you will have to create code that gets the visitors status and apply the correct template,not easy.

deeno
Joomla! Intern
Joomla! Intern
Posts: 65
Joined: Fri Nov 03, 2006 1:07 pm

Re: Load different template for logged in users in the frontend

Post by deeno » Tue Apr 23, 2024 2:23 pm

yes, it is rather huge... I could code this though, did something similar ages ago in J!2, I thought or misunderstood another info that this is by now possible out of the box/ in core... can you point me to that file(s) in J!5.1 that need to be changed?

KianWilliam
Joomla! Guru
Joomla! Guru
Posts: 565
Joined: Thu Jan 12, 2017 10:13 am

Re: Load different template for logged in users in the frontend

Post by KianWilliam » Tue Apr 23, 2024 2:40 pm

You may even go further and change the site template for each user although it does not sound very logical and I have never viewed a site like that, all you need is a user plugin and in after login event, access database and update the active site template based on the user's id in that plugin in a simple if/else or switch logic, those templates must be already uploaded to your site backend. One step more could be assigning this task to a joomla Artificial intelligence plugin to decide which template is more suitable based on the input data of each user and update the active front template automatically .
Last edited by KianWilliam on Tue Apr 23, 2024 2:51 pm, edited 2 times in total.

User avatar
Per Yngve Berg
Joomla! Master
Joomla! Master
Posts: 30966
Joined: Mon Oct 27, 2008 9:27 pm
Location: Romerike, Norway

Re: Load different template for logged in users in the frontend

Post by Per Yngve Berg » Tue Apr 23, 2024 2:46 pm

What changes do you want for the logged in users?

In the beginning of the template's index.php, assign values to variables.

Guest user is userID=0.

deeno
Joomla! Intern
Joomla! Intern
Posts: 65
Joined: Fri Nov 03, 2006 1:07 pm

Re: Load different template for logged in users in the frontend

Post by deeno » Tue Apr 23, 2024 2:50 pm

Thank you kian, but this won't work (I think):
The idea behind all this is, while in production, we need editors to be able to insert content, viewable just in cassiopeia (in order for them to see what they inserted), while our dev works on the main custom template (which is visible only for him if he is logged in the frontend)

KianWilliam
Joomla! Guru
Joomla! Guru
Posts: 565
Joined: Thu Jan 12, 2017 10:13 am

Re: Load different template for logged in users in the frontend

Post by KianWilliam » Tue Apr 23, 2024 2:55 pm

Then instead of user id, you may employ group id (editor's group id for instance), it works , I assure you, I can myself develop it for you, no charge will be exercised, I have some time which is not as precious as gold.

deeno
Joomla! Intern
Joomla! Intern
Posts: 65
Joined: Fri Nov 03, 2006 1:07 pm

Re: Load different template for logged in users in the frontend

Post by deeno » Tue Apr 23, 2024 3:02 pm

wow! thanks, sure, why not - can buy you a beer/coffee online if you have an account, or send you gladly a donation over paypal - or of course real beer/coffee sometime if you are based in germany or greece

KianWilliam
Joomla! Guru
Joomla! Guru
Posts: 565
Joined: Thu Jan 12, 2017 10:13 am

Re: Load different template for logged in users in the frontend

Post by KianWilliam » Tue Apr 23, 2024 7:45 pm

No need for that, continue the good work to enslave artificial intelligence, give me an email of yours and let us know when you want it to be prepared. God willing I shall start tomorrow, it is past midnight here. I write the logic based on the info you gave me, correct me if I am wrong, two different groups at the same time want to work on the same website, but in different pages, I will fix the template for the editors group by updating menuitem layouts from the plugin. the other groups work on other pages and default template won't be changed for them.

deeno
Joomla! Intern
Joomla! Intern
Posts: 65
Joined: Fri Nov 03, 2006 1:07 pm

Re: Load different template for logged in users in the frontend

Post by deeno » Wed Apr 24, 2024 7:35 am

@PoorRichard: thanks, but this won't work as mentioned before, because we need a solution without creating new menus with different template styles

@KianWilliams: thanks again! There is no rush at all, if you can provide the plugin by next monday it would be great.
Here one clarification on your comment:
Two different groups at the same time want to work on the same website, same/different pages should be irrelevant, because the group "editors" insert content and see only the basic/default template
while the other group "devs"/"admins" build the main template and need to check the outcome with the already inserted content of the other group - therefore, group "devs" need to be logged into the frontend, while "editors" not. The latter only needs to see quickly if all inserted content is correct, no need for a frontend login. Later, in 2-3 months, when "dev"-group is almost done with templating, and "editors"-group has inserted 80-90% of all content, we can remove7disable the plugin (your solution), and assign the main (new) template to all groups.

Is this clear sofar? It would be a shame if you work on it in vain...! Let's play ping-pong here until it is 100% clear for you. Basically/in short: one group (not logged into the frontend) sees all content rendered by the default template, another group (logged into the frontend) sees all content rendered by the new template in development.

KianWilliam
Joomla! Guru
Joomla! Guru
Posts: 565
Joined: Thu Jan 12, 2017 10:13 am

Re: Load different template for logged in users in the frontend

Post by KianWilliam » Wed Apr 24, 2024 8:37 am

Here is what I am going to do:
In the manifest file of the plugin (.xml file) I consider the option for administrator group to choose the page(s) they want to check in the custom plugin, they have to input the title of the menuitem(s) which show that page(s), and the plugin will update those pages to be viewed by the custom template. In the production phase you may remove the menuitems, but in development phase they are necessary.
The editor's group who work with default template , keep working on pages , inserting content first in the pages not to be chosen by the admin group who develop the custom template, then the page(s) who are chosen by admin to view the results of the inserted content. Admin group does not need all pages to view the development result of a custom template, And that could be told to editors group to warn them this page is under construction with new template, by the manager or a message from the plugin, or both. You can not assign two templates to the same page in joomla at the same time. Unless you create a copy backsite and one group works on it the other works on another and then the result of one transfered to the other site.

deeno
Joomla! Intern
Joomla! Intern
Posts: 65
Joined: Fri Nov 03, 2006 1:07 pm

Re: Load different template for logged in users in the frontend

Post by deeno » Wed Apr 24, 2024 9:00 am

@KianWilliam:
Unfortunately this won't do it this way. The extra while developing created menus will be a problem. Please let me check first with a colleague on this. As I wrote, I can remember doing something similar ages ago in J!2. Maybe there is another workaround as well? I will reply here soon/until friday. Thanks again!


Post Reply

Return to “Administration Joomla! 5.x”