Invision Community 4: SEO, prepare for v5 and dormant account notifications By Matt Monday at 02:04 PM
SJ77 Posted February 21, 2017 Posted February 21, 2017 Can't find it in the settings. Help? Thank you in advance.
Linguica Posted February 21, 2017 Posted February 21, 2017 You can remove the review field entirely by commenting out the line $form->add( $editorField ); in the reviewForm() method in /system/Content/Item.php but I cannot for the life of me see how to make such a field optional.
SJ77 Posted February 21, 2017 Author Posted February 21, 2017 I don't mind reviews, but I want people to be able to leave ratings without ALSO being forced to leave a review Any ideas?
Linguica Posted February 21, 2017 Posted February 21, 2017 This is something I want for my own site so I am going to keep researching. It's a little incredible just how many layers of abstraction everything goes through, and not having a debugger really slows things down. I am sure it must be possible - all form fields are handled through the same classes, and for instance, when adding custom fields to a download you can see on the edit screen that it's possible to control whether or not the editor field can be empty or not: The first is one of the "default" file download fields and the second is a custom field called "Author." They go through different paths on the back end and somewhere in there is something that makes the first one required and the second one optional... I just need to figure out what.
Linguica Posted February 23, 2017 Posted February 23, 2017 On 2/21/2017 at 3:33 PM, Linguica said: not having a debugger really slows things down. it's not quite a debugger, but I just randomly found out about being able to add this to your constants.php define('QUERY_LOG', TRUE); which will show a list of all MySQL queries to load a page, which is nice at least.
Linguica Posted February 23, 2017 Posted February 23, 2017 OK, I've found how to turn it off. I haven't made a plugin or anything but it's possible to do. Go to /system/Content/Item.php around line 3826 and edit public function reviewForm() to read public function reviewForm( $review_required = TRUE ) This introduces a variable you can pass to the reviewForm method to control if the review is required or not and sets its default value to true. Then edit a little below: $editorField = new \IPS\Helpers\Form\Editor( static::$formLangPrefix . 'review_text', NULL, TRUE, array( 'app' => static::$application, 'key' => ucfirst( static::$module ), 'autoSaveKey' => 'review-' . static::$application . '/' . static::$module . '-' . $this->$idColumn, 'minimize' => static::$formLangPrefix . '_review_placeholder' ), '\IPS\Helpers\Form::floodCheck' ); You want to edit this to $editorField = new \IPS\Helpers\Form\Editor( static::$formLangPrefix . 'review_text', NULL, $review_required, array( 'app' => static::$application, 'key' => ucfirst( static::$module ), 'autoSaveKey' => 'review-' . static::$application . '/' . static::$module . '-' . $this->$idColumn, 'minimize' => static::$formLangPrefix . '_review_placeholder' ), '\IPS\Helpers\Form::floodCheck' ); the third argument being passed has been changed from TRUE to $review_required. That argument turns out to control whether or not the form field can be left blank or not. Now go into your theme, and if you want a review form to accept blank reviews with only a star rating, look in downloads > front > view > reviews for <div id='elFileReviewForm'> {$file->reviewForm()|raw} </div> and edit it to read <div id='elFileReviewForm'> {$file->reviewForm(FALSE)|raw} </div> You can repeat this in any other template where you want to make the review portion optional.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.