[PAID] My Topics Button in Top Menu

What would you like done?
I need a button in the top menu that is similar to posted which would show you all the posts that you have created, but not include other users topics you have replied to as posted does.

It would be nice if I could rename it to ‘My Photos’ in certain categories as well.

This needs to work with the Topic Previews plugin so the results have thumbnails, which the code below does work with.

When do you need it done?
No rush, but would be nice to have it done within a month.

What is your budget, in $ USD that you can offer for this task?
I’m hoping that the code below can be used as a starting point (this is for a button to show posts that have no reply) and that it would be a pretty easy task, so I’ll offer up $100

The biggest issue I’m running into modifying this myself is that I can’t find a way to use a username variable in the search query so that it only shows the current users topics

<!-- NEEDS REPLY -->
<script type="text/discourse-plugin" version="0.8.18">
    if (I18n.translations.en) {
        I18n.translations.en.js.filters.needsreply = {title: "No Replies", help: "Topics with no replies"};
    }

    // CUSTOMIZE THESE VALUES
    // Set the search query
    let search_query = '?max_posts=1';
    // Exclude certain categories from showing the needs reply menu item
    let excludeList = ['classifieds', 'workshops', 'staff', 'wiki','site-discussions', 'site-feedback', 'announcements', 'site-tips', 'site-support'];


    // Add active class to Needs Reply button
    api.modifyClass('component:navigation-item', {
        active: Ember.computed("contentFilterMode", "filterMode", function () {
            let contentFilterMode = this.get('content').get('filterMode');
            if (window.location.search && window.location.search.split('&')[0] === search_query.split('&')[0]) {
                return contentFilterMode === "needsreply";
            } else {
                return this._super(contentFilterMode, this.get('filterMode'));
            }
        }),
    });

    // Remove max_posts filter and tags filter
    api.modifyClass('controller:discovery/topics', {
        resetParams: function () {
            this.setProperties({max_posts: null});
            this.setProperties({tags: null});
            this._super();
        }
    });

    Discourse.ExternalNavItem = Discourse.NavItem.extend({
        href: function () {
            return this.get('href');
        }.property("href")
    });

    Discourse.NavItem.reopenClass({
        buildList: function (category, args) {
            let list = this._super(category, args),
                tag = args.tagId,
                needsreplyHref;

            if (!category) { // does not have a category
                needsreplyHref = tag ? '/latest/' + search_query + '&tags=' + tag : '/latest/' + search_query; // if there's a tag build the href with the tag, else fall back to the latest view and the search query
            }
            else if (excludeList.indexOf(category.slug) != -1) { // the category is in the exclude list, do nothing
                return list; // return the list without creating the custom nav item
            }
            else if (!category.parentCategory) { // is not a sub-category
                needsreplyHref = tag ? '/c/' + category.slug + search_query + '&tags=' + tag : '/c/' + category.slug + search_query; // if there's a tag build the href with tags and the category, else fallback to the search query et al
            } else { // is a sub-category
                needsreplyHref = tag ? '/c/' + category.parentCategory.slug + '/' + category.slug + search_query + '&tags=' + tag :
                    '/c/' + category.parentCategory.slug + '/' + category.slug + search_query; // if there's a tag build the href with tags, sub-cateogry, and category, else fallback to search query et al
            }
            list.push(Discourse.ExternalNavItem.create({href: needsreplyHref, name: 'needsreply'}));
            return list;
        }
    });
</script>
6 Likes

@merefield do you think this might tie in a bit with what we are doing?

3 Likes

Yes, very likely. David, I’m going to add you to a conversation

4 Likes

Still looking for help on this…