Different landing page for desktop vs mobile theme?

No worries. I should have linked to instructions here too! There is a nice illustrated set of instructions you can check out here. It’s possible you might be on the latest version of Discourse, in which case the UX for themes and components has changed a little. Let me know if the instructions I linked to still leave you a little lost. I’d be happy to help you figure it out.

By the way, the topic below is the home of this theme component now:

2 个赞

thanks @tshenry i’ll take a look.

however I’ve just fiddled round with the customization settings - I’ve never had an issue before, and now my site has disappeared!! Just produces a blank screen, but the code is there!!

any idea how to reverse changes from the cli???

cheers

You’ll need to go to your site’s safe mode Air Cadet Central and check “disable current theme” then you’ll want to revert whatever change you made in the customizations.

2 个赞

thanks fella - didn’t know that existed! Lifesaver!

1 个赞

OK back up and working - thanks again - I’ve installed your theme and it’s installing as a Theme not a Theme Component??? any ideas. I’m on Version: v2.1.0.beta5 +66

cheers, and thanks for your hard work :smiley:

No problem. If you select it from the list of themes, then scroll down, you should see a section like this:

You’ll want to click the “make component” button then confirm. You should then be able to add it to your main theme the way it’s outlined in the instructions I linked to earlier.

Fab, getting there! Making it a component works, but when I add it to my theme it adds a component with the others but there’s no text for the link, but the (x) button is there. The link it produces ends in a # where the others don’t??
and it doesn’t seem to work!!

Cheers

Ah yeah, I think that might be a little bug that’s still getting worked out. Try refreshing the page, then click the (x) if that blank theme component is still there, then try selecting the Force Mobile Homepage component again. You might also try selecting another theme component from the dropdown list, then open the list again and select the Force Mobile Homepage component again. Click the “add” button and hopefully that should do it!

3 个赞

You are indeed a hero - now working as advertised! Many thanks for your help today, greatly appreciated!

1 个赞

Yes, I’ve come across this several times. Has this been reported I wonder?

I don’t know - I haven’t - but @tshenry 's suggestion of moving in and out of the drop down menu after a page reload worked.

1 个赞

Nice one! thanks @tshenry :heart:

1 个赞

为什么不将您的脚本与“自定义 → 主题 → 移动设备 → 页眉”中的以下代码结合使用呢?

<script>
  if (window.location.pathname == "/")
  {   window.location.href = "/latest";
  }
</script>

这样,如果用户访问首页,即可自动重定向到 /latest。

1 个赞

没有特别的原因,没有。不过,我不再使用那个脚本了。随着用户可选择主页功能的加入,我只让那些偏好 /latest 的用户选择它。

1 个赞

我最初是在搜索解决我问题的方案时发现了这个主题:

正如该主题所解释的,我将论坛设置为显示“分类 + 最新”,因为我不希望仅在桌面端显示“最新”内容。以下是实现该布局所需的两个 Discourse 设置:

对我而言,这是理想的布局,因为它既为想要发布新内容的用户展示了分类,也为其他只是回来查看最新动态的用户提供了“最新”内容。

对于想要实现同样效果的朋友,以下是你需要做的步骤:

  1. 进入你主题的 编辑 CSS/HTML 部分:

  2. 移动端页眉 部分添加以下脚本(这样它只会影响移动设备访问者):

    以下是脚本内容,你可以直接复制/粘贴:

    <script>
        if (window.location.pathname == "/")
        {   window.location.href = "/latest";
        }
    </script>
    
    <script type="text/discourse-plugin" version="0.4">
        api.changeWidgetSetting('home-logo', 'href', '/latest')
    </script>
    

更新: 上面链接的 强制移动端首页 主题组件可能是实现这一目标的更好方式。

10 个赞

能否按用户实现此功能?例如,每个用户都能在界面偏好设置中选择其在移动端的默认页面(目前已有通用设置,我们只需增加一个仅限移动端的选项)。

3 个赞

我目前也遇到了同样的问题:在桌面端,我更喜欢将分类视图设置为右侧显示最新主题。而在移动端,分类视图仅显示分类列表。在移动端,我更希望看到“最新”主题变更的视图。

如果能提供两个偏好设置就太好了:

  • 桌面端默认主页:[选择字段]
  • 移动端默认主页:[选择字段]

这是否是一个可以接受提交 PR 的功能?

7 个赞

这是否也可以作为每台设备的设置?上述变通方案并非理想选择,因为它们会强制所有移动用户(且在此方面,平板电脑难以归类)采用同一设置。很明显,根据设备不同设置不同的偏好往往更有意义,而不仅仅是区分桌面端和移动端。

1 个赞

这是轮子之后最伟大的发明!谢谢你,兄弟

1 个赞

我也很想拥有这些偏好……有什么办法可以做到吗?