Gli utenti devono completare un modulo quando creano un argomento?

È possibile richiedere agli utenti di compilare un modulo quando creano un argomento? (cioè, quando si apre la finestra per creare un argomento, far apparire un modulo all’interno dell’argomento che devono compilare)

Utilizzando il modello di argomento durante la creazione di una categoria, posso inserire alcuni suggerimenti su cosa gli utenti dovrebbero inserire. Ma questo è diverso da un modulo. I suggerimenti possono essere eliminati (quindi gli utenti meno esperti non sono sicuri di cosa farne) e la pagina inizia a diventare affollata se ci sono diversi suggerimenti sulla stessa pagina.

Un modulo offrirebbe un’esperienza utente più pulita e semplice nel caso in cui si desideri che gli utenti inseriscano alcune informazioni chiave nel loro argomento al momento della creazione.

È possibile? Ho trovato questo componente del tema, ma, anche se non sono ancora sicuro di cosa faccia, non credo che realizzi quanto ho in mente. Vedo anche questa richiesta di diversi anni fa: sembra che non sia stato intrapreso alcun intervento.

Inoltre, so che il plugin Custom Wizard permette di creare un modulo da compilare per gli utenti, ma in questo caso ho bisogno che il modulo sia all’interno di un argomento di Discourse (in modo che appaia poi come un argomento con tutte le funzionalità associate, come tag, risposte, ecc.). E ho bisogno che l’esperienza utente rimanga chiaramente all’interno dell’app (credo che il plugin Wizard porti l’utente a una pagina separata con un menu diverso, ecc.).

3 Mi Piace

This stuff is certainly technically possible in a theme component.

3 Mi Piace

A very related old topic for those who are interested:

1 Mi Piace

Thanks.

How do you think it could work?

Here are some ideas I have, though they still have some questions to answer:

Basics that are there now: Placeholders. But right now its "all or nothing"

The simplest structure I can think of to mimic form behavior would be where the “form” comes up in the editor (the “d-editor” that comes up when you hit create topic).

In that editor, you could provide different “sections”, like:

Name


Location


Issue


Each section title would be a placeholder, so when the user would click on it, the title (e.g., Name) would disappear.

So far, setting this up is possible with the placeholder text theme component.

But–that won’t quite get you there for form-like behavior, because the placeholders that are there now appear “all or nothing”, like I describe next.


Form-like behavior with placeholders. But how do you access divs in the editor?

To make this more like a form, each section has to behave independently.

Right now, with the placeholder text theme component, it’s all or nothing–if the user clicks on the editor, all of the placeholder titles disappear.

So, to have basic form behavior, instead of having all titles either appear or disappear, we’d need to have each placeholder title section behave independently. So when the user clicks on the placeholder “Name”, only that placeholder disappears, while the other placeholders (“Location” and “Issue”) stay.

That would be possible if each placeholder could be part of its own div with unique id within the text editor. Then, with jquery, you could show and hide the placeholder depending on if the user clicked in the area. That requires adding separate divs within what is now a textarea, which I am not sure how to do.

Question for this approach: How can you access divs within the editor’s textarea, so that you can take action when user clicks on them?


Alternative: using the existing template text option. But how to make the text not editable?

Probably an alternative would be that the section headers don’t “disappear” when the user clicks. So the section headers (example: Name, Location, and Issue) would be text that would stay on the page. To make it more form-like, compared to the current basic topic template default:

  1. The section header text could not be edited by the user (ie, contenteditable="false")
  2. The section break points could not be removed by the user
  3. There would be space below the section header where it’s clear the user can type. In the current default template, they’d have to go to where the text is, hit return, to create space to type.

Question for this approach: How can you enter template text, but (i) have that text be not editable by the user and (ii) have clear places for the user to enter information below each piece of text?


Maybe there is a better way to get at form-like behavior?

2 Mi Piace

You’d presumably need to perform a pass on the template before rendering a more complex set of entry fields instead of a monolithic text area.

Then post process it to insert the text in the right spots.

You’d need some markup standard to identify the headings/text entry points …

That could be a more lightweight solution as everything would be kept in the front end world. (everything would still be stored as a single text post).

The major downside of that approach would be that it would be much more difficult to search and aggregate this way …

Sounds like a fun project :slight_smile:

I am looking for something that stays on front-end for now. Parsing and searching different parts of the form is not required at this point, and I assume in most use cases. This is about being sure users enter their responses in a consistent way.

I don’t understand what you mean by these:

Spero di poter riprendere l’argomento. Spero che ci sia un modo, nel front-end, per far sì che gli utenti compilino qualcosa che sembri (per loro) un modulo. Quindi, ad esempio, quando vanno a creare un argomento, vedrebbero qualcosa come:

“Nome”


“Luogo”


“Problema”


Tutto questo può rimanere nel front-end. Non ho bisogno (sarebbe bello, ma non è necessario al momento) di analizzare le diverse sezioni di ciò che gli utenti inviano: può essere inviato esattamente come avviene ora. L’obiettivo è garantire un invio più uniforme da parte degli utenti e offrire loro un’interfaccia utente pulita quando ci sono diversi prompt.

La differenza tra questa soluzione e ciò che è attualmente disponibile aggiungendo un modello di argomento:
  1. L’utente non potrebbe eliminare questi prompt (cioè, non potrebbe eliminare “Nome”, “Luogo” e “Problema”).

  2. Idealmente, potrei aggiungere uno stile simile a quello di un modulo, per rendere più ovvio all’utente dove deve digitare. Questo permetterebbe un’interfaccia utente più pulita per un utente che crea un argomento nel caso in cui ci siano diversi prompt. Con i modelli di argomento, l’utente deve creare il proprio spazio per digitare le risposte per ogni prompt. Inoltre, la finestra di creazione dell’argomento inizia a sembrare molto affollata quando si hanno diversi prompt nel caso in cui si utilizzino i modelli di argomento attuali.

@sam aveva precedentemente risposto:

Sembra infatti che ciò sia possibile. Il mio problema principale: come posso, in un componente del tema (o in un plugin), modificare ciò che appare all’interno della finestra di creazione dell’argomento? Al momento, sembra una scatola nera iframe quando ho provato a farlo.

So che potrebbe esserci un modo per entrarci, dato che è ciò che fanno i modelli di argomento e ciò che fa il plugin placeholder. Ma non ho ancora capito come lo facciano.

Qualche consiglio su cosa posso fare con il codice per modificare ciò che c’è nella finestra di creazione di un argomento?

1 Mi Piace

Dai un’occhiata alla Guida per sviluppatori ai temi di Discourse. È da lì che iniziare.

Se ti riferisci al nome utente e alla località, si trovano nel profilo dell’utente, quindi forse non sono necessari?

Grazie per la risposta. Sono familiare con la creazione di temi e plugin. Ciò che cerco qui sono indicazioni sul codice specifico per accedere all’iframe del modulo di creazione dell’argomento. Non ho bisogno che qualcuno mi mostri tutto, ma apprezzerei qualsiasi indicazione. In passato ho avuto difficoltà a trovare un modo per apportare modifiche a quel modulo.

L’esempio relativo a nome, località, ecc. era solo un’ipotesi basata su un modulo comune. Nel mio caso specifico, ci sono diverse richieste che dovrei gestire.

3 Mi Piace

Sono anche interessato a una soluzione come un modulo che richieda agli utenti di inserire quando creano un argomento, preferibilmente avendo l’opzione di rendere alcuni campi obbligatori; alcuni di questi dati possono essere sensibili e vorrei averli archiviati in alcuni campi personalizzati nell’argomento.

1 Mi Piace

Controlla Introducing Experimental Form Templates