HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Last Minute Development

Just wanted to chime in in the row of "my last plugin for this year". @Skisma asked for something like this and II thought it might be a good candidate for a 2014 last minute coding. I hope it is not too buggy because of the haste ;)

«134

Comments

  • You are awesome @R_J‌! I'm downloading now and let you know how it is :)

  • @R_J‌ Thanks so much for developing this, this definitely gets me somewhere! Although I will note two things that would make this plugin perfect: For one, the prefix only displays when viewing the actual thread/discussion and not when viewing a list of threads/discussions. Also, it would be nice if i could specify certain prefixes to certain forums/categories..but this isn't too big a deal. The first thing would be a game changer though. If you ever get around to updating this these please let me know! Regardless, it really awesome you did this. Thanks a bunch.

  • peregrineperegrine MVP
    edited December 2014

    @vrijvlinder said:
    Here is an icon :)

    I don't see a robot. r_j is not going to be happy :wink:

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    Yes, I thought about that too... it is just too hard to come up with a robot theme about prefixes :(

  • [robot]

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    wow that would have never occurred to me, thanks!

  • peregrineperegrine MVP
    edited December 2014

    @vrijvlinder said:
    wow that would have never occurred to me, thanks!

    thats why I'm here little sister.

    then tell r_j his girlfriend signed off on the interior design of the icon.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    I wonder what R_J 's girlfriend's name is... Maybe Sabine, Ute, Inga, Lina, Gisela, Marlene ?

  • peregrineperegrine MVP
    edited January 2015

    my gut tells me it is Isolda or Angelika or Adolfina or Bernadette or Alfreda or Elfrida or Luane or Magnilda

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • R_JR_J Ex-Fanboy Munich Admin

    @> @Skisma said:

    R_J‌ Thanks so much for developing this, this definitely gets me somewhere! Although I will note two things that would make this plugin perfect: For one, the prefix only displays when viewing the actual thread/discussion and not when viewing a list of threads/discussions.

    I had only tested it with the normal layout and only after your complain found out that it doesn't work with table layout. I think this is a bug and I filed it on GitHub.
    In order to make it work, you'd have to change one of the core files. Normally I strictly disencourage that but in this case, I'd say it is totally safe. Look at line 47 of /applications/vanilla/views/discussions/table_functions.php. It should read // $Sender->FireEvent('BeforeDiscussionName') and you only have to delete the two slashes at the beginning of the line in order to make the prefix visible in discussion lists.

    @Skisma said:
    Also, it would be nice if i could specify certain prefixes to certain forums/categories.

    That is far more complicated and sorry, I guess I'll never add this functionality. But I'll upload that plugin sooner or later to GitHub and just feel free to send in pull requests!

    By the way: I updated the plugin and now you can change the list separator. That way you can use "/" as a separator and put that in the prefixes list: ♣/♠/♥/♦ => ♣/♠/♥/♦
    You can also have fun with some Unicode characters: 🎁/🎂/🎃/🎅/🎆 => 🎁/🎂/🎃/🎅/🎆

  • @R_J‌ Awesome, thanks for the info! Yea I figured that second suggestion would be complex, don't worry about it man this is great enough!

  • @R_J‌ Wow that was the simplest update to code I can think of, haha. It worked great and is now showing in discussion lists, however, without the brackets []. This really is no big deal though, the main thing is that they're showing.

  • R_JR_J Ex-Fanboy Munich Admin

    I just coded some brackets in the CSS because I have seen them in your screenshot. You could simply add them directly in the config screen: [Question];[Solved] or change the CSS so that they also appear in the table view:

    ...
    .Discussion .PrefixDiscussion:before, .DiscussionName .PrefixDiscussion:before{
        content: "[";
    }
    .Discussion .PrefixDiscussion:after, .DiscussionName  .PrefixDiscussion:after{
        content: "]";
    }
    

    or

    ...
    span.PrefixDiscussion:before {
        content: "[";
    }
    span.PrefixDiscussion:after {
        content: "]";
    }
    

    I'm no CSS hero so I couldn't tell what is "best", but either way should show the brackets also in the table view.

    You could also skip those brackets completely and do something like this instead:

    .SpQuestion {
      background-color: blue;
      color: white;
      padding: 1px;
      margin: 1px;
      border-radius: 2px;
    }
    

    or

    span.SpQuestion:before {
        content: "¿";
    }
    span.SpQuestion:after {
        content: "?";
    }
    span.SpSolved:after {
        content: ":-)";
    }
    
  • SkismaSkisma New
    edited January 2015

    @R_J‌ Awesome solutions! The first suggestion is so simple I never would have thought of, lol.

    I have one more question that I think might have to do with some CSS styling as well. Basically it's a solution for not being able to assign certain prefixes to certain categories.

    I'm wondering how I can add additional options to the list, but make them bold and unable to be selected. Doing this will allow me to organize my prefixes to their according forums. So it would look something like this when you click the dropdown menu (without the numbering):

    1. Forge Maps < Cannot Select
    2. H2A
    3. H3
    4. H4
    5. General Maps < Cannot Select
    6. Unreal
    7. Far Cry
    8. Project Spark
    9. Forge Discussion < Cannot Select
    10. WIP
    11. Tutorial
    12. Question
    13. Game Discussion < Cannot Select
    14. Destiny
    15. Call of Duty
    16. Evolve
  • R_JR_J Ex-Fanboy Munich Admin

    Not trivial. What you are speaking of are HTML OptGroups and Vanilla supports them with its function DropDownGroup so it basically could be done if the setup screen would allow arrays maybe in the form (Forge Maps)[H2A,H3,H4](General Maps)[Unreal,Far Cry,Project Spark].

    But that is not what you are looking for. You are looking for Category related selects. Maybe some lines of JavaScript could do the job. You would have to hard code the prefixes in your script but because it is your own customized solution, it might be okay that you sacrifice some flexibility.

    In order to load a custom JS you have to add a line to the plugin. Search for the line containing "AddCssFile" (around line 120) and add that line right below:
    $Sender->AddJsFile('prefixdiscussion.js', 'plugins/PrefixDiscussion');
    Afterwards create the directory/file /plugins/PrefixDiscussion/js/prefixdiscussion.js and use this for your custom JS. I'm no JavaScript super hero so here is only a rough draft and you have to get it working by yourself:

    $(document).ready(function() {
        var prefixes = new Array();
        prefixes[1]=['H2A','H3','H4'];
        prefixes[2]=['Unreal','Far Cry','Project Spark'];
        // ...
    
        $('#Form_CategoryID').on('change', function(e) {
            var prefixSelect = $('#Form_Prefix');
            prefixSelect.innerHTML = '<option value="-">-</option>';
            if (e.target.value >= 1 && e.target.value <= 4) {  // if you have 4 categories...
                $.each(prefixes[e.target.value], function(option) { 
                    prefixSelect.options[prefixSelect.options.length] = new Option(option, option);
                }); 
            }
        });
    });
    

    The main idea is to get the current chosen category from the dropdown, delete the prefix dropdown content and add a predefined array for that category to the prefix dropdown.

  • @R_J Wow thanks for this! I will give it a shot and hope I don't break anything, lol. You explain this fairly well so I think I should be fine. So basically I'll do a new prefixes[#]=['prefix name', 'prefix name', 'prefix name']; for each category I have and replace the "4" on line 10 with the number of categories I actually have?

  • R_JR_J Ex-Fanboy Munich Admin

    Yes that's it. To be slightly more precise, you have to do it like so: prefixes[CategoryID]=['prefix name', 'prefix name', 'prefix name'];

    Be aware of category order number is not the category id since you can order the categories however you like. You can see CategoryID either in the database table GDN_Category or when you look at the links in the category settings screen.
    But you might have guessed that already.

Sign In or Register to comment.