I’ve been doing freelance Discourse customization as my primary gig for almost a year at this point. And one of the most common questions I get is about static pages. “Can I just create a static sales page?” “Where’s a good place to put a FAQ without a discussion around it?”
You can likely argue the validity of these questions in most scenarios. The main response being “just close the topic.” But that doesn’t cut it for most. Thus, I decided to create this plugin to make it possible.
It’s pretty simple. You get a backend under Admin > Plugins to create, edit, and delete these pages as you like. It uses the same topic composer we’re used to. Once you have the page built, you can Enable it and share the link to the page wherever you like.
For a demo: LINK IS DEAD.
I should also note that styling is made easier with a class static-page in the wrapping div for the whole page. That way you can do whatever you want to the body of the page from a CSS standpoint in a theme.
I think that I have the same problem - this would be great, but I need the pages to be visible to anon as I have a private site and want some static pages to be exposed to the public.
@joebuhlig - this has been asked a few times in this thread. Do you have any thoughts on it?
I determined that the error is from the code using Discourse.Model, which has been deprecated (I believe in the current version of Discourse it has been fully removed, hence the new error).
I don’t think Joe is maintaining his plugins these days. Someone else will need to create a PR.
That said, we are currently working on a static page feature in core. It’s still in its early stages, but you can try it out by enabling the enable page publishing setting in your site settings. You can create a published page by opening up the post actions menu on a topic (select the … button followed by the wrench button).
Thanks Steven; from a bit of a play it isn’t possible to make them visible to anon on login-required forums. Rats - that is what I really want them for. Still pretty cool though.
It seems that the only way I can get more static content visible to non-logged in users is to either
keep it login-required and use the existing tools:
This. I know that this plugin is primarily to create static pages. However, let’s say you make a calculator application that you want to put in the page. The calculator requires an input from the user. The page still has static code, but it would update the result based on user input. Is this possible using this plugin or is it better just to make an external html/css page with js?
Ich möchte auf einer statischen Seite ein Widget eines Drittanbieters verwenden. Der JavaScript-Code dafür soll vor dem -Tag eingefügt werden. Gibt es eine Möglichkeit, dies nur auf dieser speziellen statischen Seite umzusetzen? Vielen Dank für Ihre Hilfe!
Ich teile nur, wie ich das Ausführen eines Skripts für statische Seiten erreicht habe:
<script type="text/discourse-plugin" version="0.8">
const { setDefaultHomepage } = require('discourse/lib/utilities');
const user = api.getCurrentUser();
if(!user) {
setDefaultHomepage('/page/welcome/1/'); // <--- Homepage-URL festlegen
}
api.onPageChange((url, title) => {
if(url.indexOf("/page/welcome") === 0) {
// Aktionen für diese statische Seite ausführen
}
});
</script>
Nur zur Klarstellung: Das Festlegen der Seite als Homepage ist beim Ausführen des Skripts völlig optional. Ich wollte lediglich zeigen, dass dies ebenfalls möglich ist
Danke!
Weißt du, wie man externe Skripte (nicht von derselben Domain) für eine statische Seite verwendet?
Es erscheint immer: Content Security Policy: Die Einstellungen der Seite haben das Laden einer Ressource an Inline („script-src“) blockiert. Quelle: (function injectedScript() {...
Allgemein gesprochen – was ist der beste Weg, z. B. einen Webshop ohne iframe einzubetten?
Code-Beispiel:
Ich möchte diese Anfrage gerne wieder aufgreifen. Das Plugin ist großartig, aber wenn man eine solche Seite teilt, werden immer nur die Standard-Metadaten angezeigt. Es wäre schön, wenn man Titel, Beschreibung und ein benutzerdefiniertes Bild angeben könnte. Wird das Plugin noch aktiv weiterentwickelt, oder sollte dies eher in die Kategorie Marketplace? Danke!