Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Adding text below "Write Comment" box - best practice?

I would like to add some minimal Markdown help for users just below the "comment" box:

Comment box

I can't actually find where that code is, although I assume it is produced by the $this->RenderAsset('Content'); line in my theme's default.master.php file. (I'm using the "Default with colour options" theme.)

Can anyone advise on how best to achieve this goal? I can put a box with this bit of info in the "panel", but I would prefer to put a line of help text with the html area so users can see it while they're typing.

Thanks for any help with this!

Best Answer

Answers

  • vrijvlindervrijvlinder Papillon-Sauvage MVP
    edited January 2014

    The code can be found in vanilla/views/post/comment.php

    You can find this part starts in line 54 and echo another div after the form buttons div with the content you want to add.

    $ButtonOptions = array('class' => 'Button CommentButton');
       /*
        Caused non-root users to not be able to add comments. Must take categories
        into account. Look at CheckPermission for more information.
       if (!Gdn::Session()->CheckPermission('Vanilla.Comment.Add'))
          $ButtonOptions['Disabled'] = 'disabled';
       */
    
       echo $this->Form->Button($Editing ? 'Save Comment' : 'Post Comment', $ButtonOptions);
       $this->FireEvent('AfterFormButtons');
       echo "</div>\n";
       echo $this->Form->Close();
       ?>
    

    Like I did below, see if that works

     $ButtonOptions = array('class' => 'Button CommentButton');
           /*
            Caused non-root users to not be able to add comments. Must take categories
            into account. Look at CheckPermission for more information.
           if (!Gdn::Session()->CheckPermission('Vanilla.Comment.Add'))
              $ButtonOptions['Disabled'] = 'disabled';
           */
    
           echo $this->Form->Button($Editing ? 'Save Comment' : 'Post Comment', $ButtonOptions);
           echo "<br>";
           echo "<div class="Info">you can add markdown and html this is also a 3D Printer just add your materials to the blender.</div>";
           $this->FireEvent('AfterFormButtons');
           echo "</div>\n";
           echo $this->Form->Close();
           ?>
    
  • vrijvlindervrijvlinder Papillon-Sauvage MVP
    edited January 2014

    Yes, you always have better ideas ... <3 I was starting a search on how to this via jquery , another example of my ignorance lol

  • @vrijvlinder said:
    Yes, you always have better ideas

    except when you do. I also edited above plugin - so it could be used on this vanilla forum as well :).

    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
    edited January 2014

    I figured out how to add it to the forms via jquery , amazing how many ways of doing the same thing

    I experimented with this just to see what would happen , I took the announce and close ul to replace it with text to see if it worked , it did replace those, if I want them there, I would first need to create it's own container.

    <script type="text/javascript">
    jQuery(document).ready(function(){
    $( "ul.List.Inline.PostOptions" ).text( "This is a 3D printer just add your materials to the blender");
    });
    </script>
    

    To simply add the text in that ul I figured out to use append instead of text and it just adds the text next to the other stuff.

    <script type="text/javascript">
    jQuery(document).ready(function(){
    $( "ul.List.Inline.PostOptions" ).append( "This is a 3D printer just add your materials to the blender");
    });
    </script>
    
  • @vrijvlinder

    I put a few images in the plugin screenshots as well.

    http://vanillaforums.org/addon/addtexttobox-plugin

    I guess it all depends how you want to add things, on the back-end via the plugin with out javascript - potentially faster since js isn't loaded into browser

    or on the front-end - where the browser does the work with js by your technique.

    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

    Well since being modular is always best, in the sense that if you switch themes you would need to add the jquery all over again, the plugin is always the best option in my opinion.

    Both work to do the job, however your plugin is the most practical solution. Specially because it makes it easier to style and place better.

    Way to go p!! I have an icon in mind but first let me know if you need one ;)

  • peregrineperegrine MVP
    edited January 2014

    @vrijvlinder said: I have an icon in mind but first let me know if you need one

    to paraphrase:
    Yes, you always have better ideas ... :heart: when it comes to plugin icons.

    ok, thanks.

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

  • I'll update the plugin to use Definitions as soon as you post icon, and i 'll do it all in one fell swoop.

    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

    ok I made this one see if you like the concept

  • erajaderajad New
    edited January 2014

    Completely genius! Thank you both for your help with this. I was thinking of a solution like @vrijvlinder's original one (I know too little to write a plugin ... core hacking ... not good but I would do it). But @peregrine's plugin solution was ideal. I ended up with this:

    AddTextToBox

    And I tweaked the code slightly, since I wanted the same message in both places, and but only wanted to type it once. (Makes any future tweaks much more simple.) So I defined a "var" and echoed it instead. Link Redacted - hope that's OK!

    Many, many thanks for this help. (That was a far more productive question than my last one! ;) )

  • vrijvlindervrijvlinder Papillon-Sauvage MVP
  • peregrineperegrine MVP
    edited January 2014

    @vrijvlinder

    version 1.1 is up with your icon. V, thanks.

    @erajad
    Many, many thanks for this help. (That was a far more productive question than my last one!

    glad it worked. for you. I'm not to keen on people posting entire code for a plugin or even extraneous code when a snippet will do, or posting on other sites, and more easily viewed when a snippet can be inserted via code tags on this site. but oh well, thats my opinion.

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

  • erajaderajad New
    edited January 2014

    @peregrine - I'm still learning! On other sites/forums that I know better, posting in a gist (or pastebin the like) is what I'm used to. I've deleted the Pastebin code (link now 404s - I was just a minute or two too late to edit my post; if anyone with admin rights wants to remove it, please do), so here is my tweak. First, add the string as variable inside the class:

    // Define help string:
    
    var $string = '<span style="font-size:smaller;padding-bottom:6px;">Use <a href="http://daringfireball.net/projects/markdown/syntax" target=_blank>Markdown↗</a> | Quick help: <code style="background-color:#fff;">*italics* , **bold** , [link text](url) , - list item , > Quoted text... </code></span>';
    

    Then echo it in the function this way:

    echo $this->string;
    

    Thanks again!

  • peregrineperegrine MVP
    edited January 2014

    its just my preference. i prefer not to have the entire code posted anywhere, because i can't track downloads. and then when someone cuts and pastes entire code from an old version that someone else posted. i end up spending time explaining that they should use the new version.

    no worries. lines 14-24 would have been suitable as a snippet, instead of entire code.

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

  • erajaderajad New
    edited January 2014

    Right - that's understandable. (And was in time to adjust my post, above ;) )

    Bwt - I just took a look at v. 1.1 (already!). The locale.php option looks excellent. In the Readme.txt file the instruction is given to create a local.php file - I assume that needs a "e"?

  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    Yes that makes sense, specially since people can use code snips to search on google, it would be preferable that google points it back to here and not to paste bin or others. It also makes sense for quality control.

  • @erajad said:
    Right - that's understandable. (And was in time to adjust my post, above ;) )

    Bwt - I just took a look at v. 1.1 (already!). The locale.php option looks excellent. In the Readme.txt file the instruction is given to create a local.php file - I assume that needs a "e"?

    thx. I put a note in the description.

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

Sign In or Register to comment.