mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: Allow to modify topic-backed static pages (#15324)
A plugin API that allows customizing existing topic-backed static pages, like:
faq, tos, privacy (see: StaticController) The block passed to this
method has to return a SiteSetting name that contains a topic id.
```
add_topic_static_page("faq") do |controller|
current_user&.locale == "pl" ? "polish_faq_topic_id" : "faq_topic_id"
end
```
You can also add new pages in a plugin, but remember to add a route,
for example:
```
get "contact" => "static#show", id: "contact"
```
This commit is contained in:
@@ -994,6 +994,22 @@ class Plugin::Instance
|
||||
DiscoursePluginRegistry.register_notification_consolidation_plan(plan, self)
|
||||
end
|
||||
|
||||
# Allows customizing existing topic-backed static pages, like:
|
||||
# faq, tos, privacy (see: StaticController) The block passed to this
|
||||
# method has to return a SiteSetting name that contains a topic id.
|
||||
#
|
||||
# add_topic_static_page("faq") do |controller|
|
||||
# current_user&.locale == "pl" ? "polish_faq_topic_id" : "faq_topic_id"
|
||||
# end
|
||||
#
|
||||
# You can also add new pages in a plugin, but remember to add a route,
|
||||
# for example:
|
||||
#
|
||||
# get "contact" => "static#show", id: "contact"
|
||||
def add_topic_static_page(page, options = {}, &blk)
|
||||
StaticController::CUSTOM_PAGES[page] = blk ? { topic_id: blk } : options
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def self.js_path
|
||||
|
||||
Reference in New Issue
Block a user