Help centers using the documentation layout now render correctly in two cases that previously fell back to the wrong output. Opening a portal at its custom-domain root (e.g. docs.example.com/ ) now shows the full documentation home in place instead of the classic layout, and portals whose locale is a region variant that Chatwoot doesn't ship a translation for (e.g. th_TH , fr_ML ) now show their categories in the sidebar on article pages. Closes https://linear.app/chatwoot/issue/CW-7437/portal-layout-is-not-properly-working-in-custom-domain ## How to test 1. Create a portal with the documentation layout and a custom domain (e.g. example.chat.test ), with at least one category containing a published article. 2. Visit the custom-domain root ( http://example.chat.test:3000/ ) → it should show the full documentation home (sidebar, topbar), not the classic layout, with no redirect. 3. Set the portal's locale to a region variant Chatwoot doesn't translate, e.g. th_TH , with categories/articles under that locale. 4. Open an article → the sidebar should list the article's category and sibling articles. Before the fix the sidebar was empty for these locales. --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
37 lines
1.2 KiB
Ruby
37 lines
1.2 KiB
Ruby
class Public::Api::V1::PortalsController < Public::Api::V1::Portals::BaseController
|
|
include PortalHomeData
|
|
|
|
before_action :ensure_custom_domain_request, only: [:show]
|
|
before_action :redirect_to_portal_with_locale, only: [:show]
|
|
before_action :portal
|
|
before_action :set_portal_layout
|
|
before_action :set_view_variant
|
|
before_action :ensure_portal_feature_enabled
|
|
before_action :load_home_data, only: [:show], if: -> { @portal_layout == 'documentation' }
|
|
layout 'portal'
|
|
|
|
def show
|
|
@og_image_url = helpers.set_og_image_url('', @portal.localized_value('header_text', @locale))
|
|
end
|
|
|
|
def sitemap
|
|
@help_center_url = @portal.custom_domain || ChatwootApp.help_center_root
|
|
# if help_center_url does not contain a protocol, prepend it with https
|
|
@help_center_url = "https://#{@help_center_url}" unless @help_center_url.include?('://')
|
|
end
|
|
|
|
private
|
|
|
|
def portal
|
|
@portal ||= Portal.find_by!(slug: params[:slug], archived: false)
|
|
@locale = params[:locale] || @portal.default_locale
|
|
end
|
|
|
|
def redirect_to_portal_with_locale
|
|
return if params[:locale].present?
|
|
|
|
portal
|
|
redirect_to "/hc/#{@portal.slug}/#{@portal.default_locale}"
|
|
end
|
|
end
|