Custom Homepage for Groups

Overview

When installed and added to the active theme, this theme component enables you to control the ‘homepage’, allowing it to be different from the set of pages Discourse allows by default, as well as having different groups have different “homepages” (e.g., group members care only or mostly about a particular category). This can be for all users, anon (non-logged in), mobile users, or according to a user’s primary group. Initially developed by @pfaffman. See User-specific Discourse home page.

Use-cases:

  1. You want something other than the ‘normal’ homepage
  2. You want a different homepage for Anonymous users
  3. You want a different homepage for Mobile users
  4. You have a group of folk only interested in using a small slice of your instance. They want to only see their specific category.
  5. Temporarily redirect a group of your punters to a special event or the like.
  6. Have different landing pages for different groups.

Settings

custom default homepage

Allows you to set a global custom homepage.

anon page

This enables you to use a specified page for those who aren’t logged into your site. Over-rides the global one above.

mobile homepage

As per Force Mobile Homepage this allows you to set a different homepage for mobile users. This will override the options chosen above.

group page map

This allows for multiple entries. Each entry should be of the format group_name:path , where group_name is the group slug (not the group Full Name ) and the path is the desired home page (e.g., “/c/great-category/4”).

Ensure that the target users have the specified group denoted as their primary group and you are away. If the theme setting or the user primary group is changed, a reload will be required to have the change take effect.

:warning: The users with a specified group as primary will not be able to reach your ‘normal’ homepage unless you ensure that there is a way for them to do that (such as the native sidebar functionality)

Known Issue - limited to relative URLs

And that doesn’t include Page Publishing, unfortunately. However, you can workaround this by creating a permalink that will redirect to the external site and point to that permalink.

  • @pfaffman tested this with a permalink at /go-google that redirects to https://google.com and something like group-name:/go-google
  • you create Permalinks via the admin settings /admin/customize/permalinks
38 Likes

This is a game group changer! :crazy_face:

Good job! Rather powerful TC…

We’ve got a few tweaks at the PR stage, addressing these:

And also adding control of the mobile homepage if you wish it to be different (as per Force Mobile Homepage).

This increases its power significantly, so hope you like it.

6 Likes

Hello!! This is awesome!! :slight_smile:
Thank you very much, this is actually important for my my case (use-case 1).
I have to ask, about " The users with a specified group as primary will not be able to reach your ‘normal’ homepage", what do you mean by “actively provide a way for them to do that” ?
Also, in line with this concept, it will also be useful to show in the homepage a specific order of the categories depending on which group the user belongs to. For example, to show their category at the top, and all the rest below of that. Do you think this is possible? (if not already?).

It means that whatever home page you set in the site settings will be overridden. So if you want users to be able to get there then you’ll need to see that there is a link to get there… Somehow.

I can’t imagine how that would work (maybe I have a bad imagination :man_shrugging:). The use case that I can think of makes users have a different category set as home if the are in a group. Like a car site could let you choose the Ford group as your home page.

If you want different stuff available for different groups then I think you’d do that by having default muted categories.

1 Like

Hi Jay!
Thank you for your answer :slight_smile:
Lets say I would like to have different categories “pinned” at the top depending to which group a user belongs to. I mean, each different user would see a different “pinned” category. I don’t want to hide the other categories from the user, just make easily visible and readily available the one they will be using the most, right from the homepage (if possible!).
(of course, I’m not “demanding” anything here, just asking if it’s possible with available settings/components)

1 Like

Hey @lisandro_iaffar

I had a the exact use case which I posted here: Showcased Categories Theme Component - #18 by jrgong

In my case I set up my advertiser’s client category as homepage with this TC, but they just found it confusing and asked me to remove it again. Hence I think the showcased categories tc with such a modification would be the perfect solution.

3 Likes

Hi @jrgong! :slight_smile:
Thank you very much for pointing me to that topic! And yes! That would be just perfect! I’m moving there to support the idea :muscle:
Thank you again!

I just submitted an update that deals with the new preLoadStore, which was causing it to have the wrong topics displayed on first load.

5 Likes

Hey Jay, I’ve noticed an error after my last Discourse update:

image

1 Like

Are you sure that’s the most recent version in github? (Not your fork or a static/local version?) I just ran an upgrade and it’s working. Also looking at the code, there’s only one place where api is used:

        const user = api.getCurrentUser();

and that’s inside a block that definces api.

That is odd. I’ve removed it from that instance anyway as it was surplus. And it seems to be working fine after updating in another instance. Weird. Thanks for taking a look!

Any idea how it interacts with the sidebar? I need to give it a whirl as it looks like the issue of needing a route back to the forum home has been solved by it.

1 Like

I’ve not tested, but I can’t imagine why not. Please note, I may not have a very good imagination.

1 Like

I’m testing this now, but have two comments:

  1. The anon path is not working for us - does it require the same format as the group map?
  2. It would be great if there’s a default setting that would just apply to everyone.

1 Like

Hmm. I thought I’d tested it on the list commit.

Indeed. I guys the people who needed it didn’t need to change to a non-supported home page.

I’ll try to have a look tomorrow though it may be next week.

1 Like

FWIW It worked for me when I was playing with it yesterday (I had tag/featured/ in there)

It is working fine for me. It only needs the relative path.

But I had the same problem as you until I actually added the component to the Theme! Have you done that?

Yeah, I did think that needed adding. Here 'tis:

2 Likes

Yeah, the same theme works fine when logged in, just not for anon. And just to be sure: the relative URL needs to start with a /? Asking because Jammy used tag/featured/ while I use /c/artwork/8.

I got this to work - it was a mistake on my end.

Perfect, thanks! It’s not showing for me as an update yet though - should it?

1 Like

It is in my fork. You can install that directly yourself from here if you like until Jay merges it:

Works with or without a /

BTW

The way you have it configured won’t work as users can’t have any of the trust_level groups as their primary group.

Thinking about that - is it added to the default theme for the site (anon uses this)? I’ve been tripped up by adding a component to my ‘dev’ theme but not the default theme.

2 Likes

Yeah I found the mistake - it was related to that :man_facepalming:

2 Likes