Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Adding a new field to discussion form
I'd like to develop a extension that will (1) add a new field to the original post of a discussion that (2) saves to the database and (3) can be called back into a variable.
To be more specific, I'd like the user to be able to list comma-separated numbers that will be passed into an array that will create a sparkline graph from a script.
I'm quite willing to read up on whatever documentation that I need to do so, but was hoping Minisweeper or another vet could give me some general advice to point me in the right direction. (I know PHP, but am a complete novice at Vanilla extension development.)
To be more specific, I'd like the user to be able to list comma-separated numbers that will be passed into an array that will create a sparkline graph from a script.
I'm quite willing to read up on whatever documentation that I need to do so, but was hoping Minisweeper or another vet could give me some general advice to point me in the right direction. (I know PHP, but am a complete novice at Vanilla extension development.)
0
This discussion has been closed.
Comments
Next step: Process the field and add to database
Coming up: adding to comment page (currently commented out), but displaying the field only for post author.Any ideas?
Code so far:
<?php /* Extension Name: Sparkline Progress Extension Url: http://www.gtdorgtfo.com/ Description: Adds a sparkline to the dicusssions page Version: 0.1 Author: Taylor Buley Author Url: http://www.taylorbuley.com */ $Configuration["Sparkline_PATH"] = 'extensions/Sparkline/'; $Context->Dictionary['sparklabel'] = '% complete'; if (in_array($Context->SelfUrl, array("post.php", "comments.php"))) { class Sparkline { var $Name; var $Context; function Sparkline(&$Context) { $this->Name = "Sparkline"; $this->Context = &$Context; } function Sparkline_Create() { $result = mysql_query("SELECT DefaultFormatType FROM GTD_User WHERE UserID = '".$this->Context->Session->UserID."'"); $row = mysql_fetch_row($result); if ($row[0] == 'NULL' OR $row[0] == 'Text') { echo '<div id="Sparkline" style="display:none;">'; } else { echo '<div id="Sparkline">'; } echo '<label for="PercentageComplete">How much have you completed so far? <small>(optional)</small></label><input id="PercentageComplete" name="PercentageComplete" type="text" value="" maxlength="20" /><br><br>'; echo '</div>'; } } function AddSparklineFormtoCommentForm(&$DiscussionForm) { $Sparkline = new Sparkline($DiscussionForm->Context); $Sparkline->Sparkline_Create(); } if( $Context->Session->UserID > 0) { //$Context->AddToDelegate("DiscussionForm", "CommentForm_PreCommentsInputRender", 'AddSparklineFormtoCommentForm'); $Context->AddToDelegate("DiscussionForm", "DiscussionForm_PreCommentRender",'AddSparklineFormtoCommentForm'); } } ?>