Also today I realized that the User Profile page actually displays the custom field as it should, although compared to the user card, now the custom field (Website) is displayed last instead of first…
I feel like I’ve seen a discussion of this, but I can’t find it now.
I’ve got a custom profile field that holds a user’s website implemented using this tutorial, but allowing for any external site to be entered, rather than just linking to Twitter or something. The problem I have is that about 80% of the users don’t bother to put “http(s)://” in front of the URL they enter. They (rightly) expect that “www.example.com” should just work. So how do I make it just work?
Edited to add: Figured it out. Below is the entire if block of javascript I used to determine whether to attempt to show an external link. The inner if is what determines whether the external URL needs to have “http” added to it, and takes care of doing it.
if (userFields && userFields[churchURLFieldId]) {
const rawChurchURL = userFields[churchURLFieldId];
var url = rawChurchURL;
if (!/^https?:\/\//i.test(rawChurchURL)) {
url = 'http://' + rawChurchURL;
}
const link = "<a href='"+url+"' target='_blank'>"+userFields[churchNameFieldId];+"</a>";
return Ember.Object.create({ link, name: churchURL.get('name') });
} else {
return null;
}
Is there a way to edit existing user profile fields rather than adding new one? So that the existing twitter field value can be edited to contain anchor tag
the main post that allows us to add new clickable profile fields using connectors/handlebar outlets etc, those get “added” and so I had to hide the existing profile fields
e.g. I could add a clickable twitter field and so have to hide the existing twitter field
Now the newly added twitter field will be in a separate div rather than belonging to that same ember div which was pre-existing, resulting in weird css
Would using /connectors/user-profile-public-fields/Twitter instead of using /connectors/user-profile-primary/ help here?
¡Esto es muy bueno! Lo bifurqué e intenté hacerlo un poco más general como un componente de tema sin los elementos específicos de Namati. ¡Espero que no te importe!
También agregué una publicación separada para que sea más fácil de encontrar para otros:
Hola a todos, solo quería compartir que he creado una versión muy básica de plugin de esto. Solo permite especificar qué campo de usuario convertir en un enlace y, opcionalmente, un prefijo (por ejemplo, https://mysite.com/users/). Pensé en compartirlo por si alguien prefiere instalar un componente de tema en lugar de modificar el código. Está basado en el código del mensaje original de este hilo.
Por cierto, para mi caso de uso específico, no quiero que ningún usuario pueda editarlo; más bien, planeo actualizarlo mediante la API de Discourse. En ese caso, ¿sería mejor un “campo personalizado” que un “campo de usuario”? Veo ambos en la API, pero custom_fields están vacíos.
@wilson29thid ¿estarías dispuesto a configurar un tema Theme para este componente? Sería genial tener esto como un componente de tema instalable en lugar de requerir que las personas copien y peguen el código cada vez.
Claro, ¿crear un tema aquí con esa etiqueta hace que sea instalable?
Ya es instalable a través de la URL de git. Crear un tema solo ayudará a la gente a encontrarlo más fácilmente.
Pregunta ligeramente diferente. Quiero añadir un enlace que se abra en una ventana diferente a la descripción de un campo de usuario en la página de registro. Esa página no reconoce los enlaces envueltos en [esto](formato).
Quiero que los usuarios acepten que han leído nuestros valores comunitarios antes de unirse, y tener un enlace allí ayudará si se los han perdido. Ahora mismo, solo les he dicho que copien/peguen el enlace completo en su navegador.
¿Cómo funciona esto con Discourse 3.2 y Ember 5?
He actualizado la versión: \u003cscript type=\"1.13.0\"\u003e y he cambiado api.registerConnectorClass por api.renderInOutlet como se sugiere aquí pero obtengo en la consola del navegador: [THEME 27] Error: klass is not an Ember component
He cambiado property por computed como se sugiere aquí pero obtengo en la consola del navegador: [THEME 27] ReferenceError: computed is not defined
Oh, olvidé la importación, así que agregué la import EmberObject, { computed } from '@ember/object'; faltante después de la etiqueta de script de apertura, pero eso resulta en un SyntaxError: "/discourse/theme-27/discourse/initializers/theme-field-140-common-html-script-3: ‘import’ and ‘export’ may only appear at the top level.
Hmm sí, las técnicas sugeridas en el OP están bastante desactualizadas (lo cual tiene sentido, dado que fue escrito en 2016
).
Hoy en día, este tipo de cosas deberían empaquetarse en un repositorio de git y publicarse como un Theme component para que la gente lo instale y configure a través de la configuración.
Sin embargo, volví a trabajar en el TC de @wilson29thid aquí, aunque todavía tiene una advertencia de depreciación que necesito solucionar en algún momento.
Esta funcionalidad de la OP ahora se puede encontrar en un nuevo minicomponente: