Installing multiple copies of a theme that uses a data-template to modify user cards/profiles breaks both

I was working on setting up my fork of the Custom Profile Link Component, and I needed two for different site links. However, currently, only users who have a username set for both sites show up. How can I ensure that both show up regardless of whether the other copy works or not?

Honestly, it might not be the data-template, but that’s what I guessed it might be from looking at it for a bit.

I’m not fully grasping what you are doing but perhaps it’s because you are writing to the same handlebars template twice rather than once (with two fields)?

1 Like

That was my suspicion as well, but I’m not sure how to work around that.

can you not use one template? should be able to setup two fields on it, unless I am misunderstanding what you are trying to do. Did you get one link field to work? If you did, that’s great :slight_smile:

2 Likes

One of the templates is for the user card, the other is for the user profile, so I don’t think so.

It works when one of two conditions are met:

  1. You have two copies, two fields and the user you’re viewing has both names filled out
  2. You have one copy, one field, and the user you’re viewing has the name filled out
1 Like

oh ok, I misunderstood, I figured you were putting 2 different links on the user card. Now it makes sense. yea two templates.

2 Likes

I am, in a way, since I’m using one per copy of the Theme Component, which I suspect to be the root of the problem. I could be wrong about that though.

I fed that chunk of code into Lola bot with no context and here was her reply:

Are you saying that you forked the theme and then include your fork and the original one? You’ll need to change all of the references to it’s variables and the id passed to modify class.

The original no longer functioned properly on Discourse, so I created a fork and revised it until it worked. At this time, I’ve installed two copies of my fork, which seem to be conflicting with each other.

That’s what I’m saying. You’ll need to rename stuff so that it doesn’t conflict.

You likely want to make one theme do both things rather than having two copies.

How would I do that exactly? One thought I had was to add the TC’s ID to the handlebars, but I’m not sure how I would do that.

Wouldn’t that sort of break the original use-case of this theme component?

I don’t know, but I though it was broken already? :wink:

If it adds a link using a custom field and you want it to add two then you’d write it such that it could be configured to include any number of links to custom fields?

I made my fork to fix bugs with the original, so I’d hope mine isn’t broken.

That could work, but I’m not sure how to do that.

1 Like

I’ve started working on this. My first real roadblock here is processing multiple IDs. I think I would do it using a foreach loop (like I’ve done higher in the code), but I’m unsure how to do that in Handlebars.

Sounds like you’re on the right path.

I can never remember and Google “handlebars for loop” and find examples.

After fiddling with this for about an hour, I’m going to say I’m stumped. This code:

          {{#each this.customProfileLink as |links|}}
              <a href="{{link.[2]}}{{link.[0]}}" target="_blank">{{link.[1]}}</a>
              <p>{{link}}--{{link.content}}</p>
          {{/each}}

Feels like it should work, but everything I can find on #each seems to vary, and this doesn’t work. Anyone have any insight here?

And that one was doubly on me. :facepalm: Used links for the item, and link in the processor. And I didn’t check the user profile, only the user card (User profile was correct for some reason)