* This tutorial is using the
Hi, here I'm going to share how to use OUGC Custom Reputation xThreads integration to hide thread field data unless users rate a thread. You should be aware that xThreads only works on threads or first posts and thus this feature isn't meant to work on replies or regular not first posts.
For this tutorial we are going to use the most basic integration feature, which allows us to require users to rate a thread using any rate available. Later we could expand this tutorial to explain how to allow users to request specific ratings rather than any available.
Because of this, we are going to skip the process of adding custom reputations, as this tutorial assumes that you have already created some that are available for all users in all forums (the default custom rating created at installation should work with this tutorial).
Configure
The first step is to add the OUGC Custom Reputation function to the white list of xThreads functions. If you have already configured your fields you will need to save the fields again so that the cache gets updated.
xThreads Field
Next step would be us creating and configuring our xThreads field, which will be hidden content. We are going to create a basic text field using the following details:
Any field not mentioned configure as you see fit.
Configure OUGC Custom Reputation
Then, we need to configure OUGC Custom Reputation plugin settings.
Template Edits
Finally, we need to edit two xThreads templates.
We are basically just adding an ID to the parent HTML tag in these templates. Thi will allow both, the hiding of the field in the edit post page and Ajax support for updating content.
I decided to integrate xThreads support in OUGC Custom Reputation because the plugin already offers a lot of features. You can, for example, create file fields, which you can configure to hide until the users rate the thread.
You can test that example in this community, in the thread Tutorial Replacing MyBB ratings with Semantic UI ratings module. you are required to rate the thread to view the attached file.
Eventually I could expand this tutorial to describe additional configurations.
develop
branch from GitHub. Official support will be for future release to be marked as 1.8.22
.Hi, here I'm going to share how to use OUGC Custom Reputation xThreads integration to hide thread field data unless users rate a thread. You should be aware that xThreads only works on threads or first posts and thus this feature isn't meant to work on replies or regular not first posts.
For this tutorial we are going to use the most basic integration feature, which allows us to require users to rate a thread using any rate available. Later we could expand this tutorial to explain how to allow users to request specific ratings rather than any available.
Because of this, we are going to skip the process of adding custom reputations, as this tutorial assumes that you have already created some that are available for all users in all forums (the default custom rating created at installation should work with this tutorial).
Configure
phptpl_allowed_funcs.txt
The first step is to add the OUGC Custom Reputation function to the white list of xThreads functions. If you have already configured your fields you will need to save the fields again so that the cache gets updated.
/inc/xthreads/phptpl_allowed_funcs.txt
Access your site server files and open this file to edit it.
- Add
ougc_customrep_xthreads_hide
at the end of the file, in a new line if you want.
xThreads Field
Next step would be us creating and configuring our xThreads field, which will be hidden content. We are going to create a basic text field using the following details:
- Key:
ougc_customrep_content
There is no restriction regarding this value, just take note on all the times this is found within this tutorial once you create additional fields.
- Applicable Forums: This field will be activated in all forums, remember this tutorial considers your users have rates available in all forums. If there are no available rates users could be unable to view the content.
- Hide Thread Field: Don't activate this options as Ajax support won't work and users will need to reload the page to see updates. It is possible to make Ajax features work even if hiding the field, but that isn't covered in this tutorial.
- Input Field Type:
Multiline Textbox
This field is going to behave similar to the message field.
- Editable by / Required Field?:
Everyone
Any user will be able to use this field if they wish to.
- Description:
Users will be required to rate this thread to see this content.
- Field Input Width:
160
- Field Input Height:
20
- Display Parsing:
Use MyBB Parser (MyCode)
- MyBB Parser Options: Activate all options but HTML parsing:
- Allow newlines
- Filter Badwords
- Allow MyCode
- Allow [img] MyCode
- Allow [video] MyCode
- Parse Smilies
- Allow newlines
- Use Custom Input HTML:
Yes
- Input Field HTML:
<script type="text/javascript"> <!-- $(document).ready(function() { OUGC_CustomReputation.xThreadsHideSet('ougc_customrep_content'); }); //--> </script>
This will avoid the field from hiding in the edit post page (a feature that isn't exploited in this tutorial).
- Blank Replacement Value:
<script type="text/javascript"> <!-- $(document).ready(function() { $('#xt_ougc_customrep_content').hide(); }); //--> </script>
This will hide the xThreads field if not content was inserted by the user.
- Display Format:
<?=ougc_customrep_xthreads_hide({VALUE})?>
This is what will actually do the trick. This function has more options but non is covered in this tutorial.
- Viewable by Usergroups: You can restrict the content to be viable only for specific groups.
- Save the field.
Any field not mentioned configure as you see fit.
Configure OUGC Custom Reputation
Then, we need to configure OUGC Custom Reputation plugin settings.
- Go to
Home » Board Settings » OUGC Custom Reputation
- Active xThreads Hide Feature: Select the field you just configured. You can select multiple fields because there is not a set limit to the amount of configurations you can set.
Template Edits
Finally, we need to edit two xThreads templates.
showthread_threadfield_row
:
<tr id="xt_{$k}"><td width="15%" class="{$bgcolor}"><strong>{$title}</strong></td><td class="{$bgcolor}">{$value}</td></tr>
post_threadfields_inputrow
:
<tr class="xthreads_inputrow" id="xt_{$tf['field']}"> <td class="{$altbg}" width="20%"><strong>{$tf['title']}</strong></td> <td class="{$altbg}">{$inputfield}<small style="display: block;">{$tf['desc']}</small></td> </tr>
We are basically just adding an ID to the parent HTML tag in these templates. Thi will allow both, the hiding of the field in the edit post page and Ajax support for updating content.
I decided to integrate xThreads support in OUGC Custom Reputation because the plugin already offers a lot of features. You can, for example, create file fields, which you can configure to hide until the users rate the thread.
You can test that example in this community, in the thread Tutorial Replacing MyBB ratings with Semantic UI ratings module. you are required to rate the thread to view the attached file.
Eventually I could expand this tutorial to describe additional configurations.
This post was last modified: 26 Apr, 2020, 4:50 am by Omar G..