• Dev
  • flarum/tags - Very simple question regarding the top level tag.

Is there a way to make it where when I select the state, it drops down the menu with the secondary tags?

The current behavior just takes me straight into that tag/category. Then the secondary tags become visible.

Even if it could just show all children tags for all parent tags at all times that would be fine.

I tried digging around in
js\src\forum\components\TagLinkButton.js

export default class TagLinkButton extends LinkButton {
  view(vnode) {
    const tag = this.attrs.model;
    const description = tag && tag.description();
    const className = classList('TagLinkButton hasIcon', { child: tag.isChild() }, this.attrs.className);

    return (
      <Link className={className} href={this.attrs.route} style={tag ? { '--color': tag.color() } : undefined} title={description || undefined}>
        {tagIcon(tag, { className: 'Button-icon' })}
        <span className="Button-label">Test {tag ? tag.name() : app.translator.trans('flarum-tags.forum.index.untagged_link')}</span>
      </Link>
    );
  }

  static initAttrs(attrs) {
    super.initAttrs(attrs);

    const tag = attrs.model;

    attrs.params.tags = tag ? tag.slug() : 'untagged';
    attrs.route = app.route('tag', attrs.params);
  }
}

    Lej this is unfortunately not configurable in the bundled tags extension.

    You would have to fork the tags extension to modify the code, or write your own tag sidebar component through a second extension and put it in place of the default one. Using a second extension or local extender is more practical as it will allow you to update Flarum and the tags without any issue if there is any feature or security update.

    As for the code required, it shouldn't be very difficult to make either show all, or load all + show on toggle. But I don't think there's any example ready.

    • Lej replied to this.

      clarkwinkelmann I was actually just typing up an email to see if this is something you'd be interesting in coding. I am happy to pay! I assume this wouldn't be anything to difficult. It would be awesome if there was just a small drop down on primary tags, that would populate the child tags underneath. The parent tag would still be clickable of course.

      Side note, I did eventually find some posts from 2019 pointing to the:
      \js\src\forum\addTagList.js file.

         sortTags(tags)
            .filter(
              (tag) => tag.position() !== null && (!tag.isChild() || (currentTag && (tag.parent() === currentTag || tag.parent() === currentTag.parent())))
            )
            .forEach(addTag);

      changed to:

      sortTags(tags).forEach(addTag);

      Gets me close, but only loads the first parent's child tags, (one is missing?), and then if you click a second parent tag, it populates the tags for the first parent (including the one that was missing), the newly clicked parent, etc.

      This returns all tags:

      	const tags = app.store.find('tags', {
      		include: 'parent,children'
      	});

      This only returns the parents + first parents childs.

      const tags = app.store.all('tags');