DragonByte Credits: Change Charge BBCode Styling

2Tap

Active member
Registered
Joined
Aug 8, 2022
Messages
25
Points
3

Reputation:

Hello,

Is there a way to change the styling of the charge bbcode to something like this

dCoPRko.png


Instead of just a button?

Discord_XfIC1nA9Tx.png
 
Last edited:

BattleKing

Spirit of darkness
Staff member
Administrator
Moderator
+Lifetime VIP+
S.V.I.P Member
Collaborate
Registered
Joined
May 24, 2020
Messages
3,529
Points
523

Reputation:

2Tap

Active member
Registered
Joined
Aug 8, 2022
Messages
25
Points
3

Reputation:

View previous replies…

BattleKing

Spirit of darkness
Staff member
Administrator
Moderator
+Lifetime VIP+
S.V.I.P Member
Collaborate
Registered
Joined
May 24, 2020
Messages
3,529
Points
523

Reputation:

send the link to that post please I do not want to search for it
BattleKing
Blok.png


You can change the src\addons\DBTech\Credits\BbCode\Charge.php script in renderButtonForUser to your needs, like:

PHP:
                <div style="display: flex;border-style: solid;border-color: blue;color: #4DA9F4;background-color: rgba(    46, 61, 150, 0.15);align-items: center !important;">
                    <span>Click any button to proceed</span> 
                        <span style="margin-left: auto !important;">
                            <input type="button" style="float:right!important" class="button" value="' . \XF::phrase('dbtech_credits_costs_x_y', [
                            'param1' => $charge->Currency->getFormattedValue($charge->cost),
                            'param2' => $charge->Currency->title
                        ]) . '" />
                        </span>
                    </span>
                </div>

But I would suggest to use css classes for such kind of things.
 

2Tap

Active member
Registered
Joined
Aug 8, 2022
Messages
25
Points
3

Reputation:

View attachment 30024

You can change the src\addons\DBTech\Credits\BbCode\Charge.php script in renderButtonForUser to your needs, like:

PHP:
                <div style="display: flex;border-style: solid;border-color: blue;color: #4DA9F4;background-color: rgba(    46, 61, 150, 0.15);align-items: center !important;">
                    <span>Click any button to proceed</span>
                        <span style="margin-left: auto !important;">
                            <input type="button" style="float:right!important" class="button" value="' . \XF::phrase('dbtech_credits_costs_x_y', [
                            'param1' => $charge->Currency->getFormattedValue($charge->cost),
                            'param2' => $charge->Currency->title
                        ]) . '" />
                        </span>
                    </span>
                </div>

But I would suggest to use css classes for such kind of things.
BattleKing
PHP:
        if (!$visitor->user_id)
        {

Pasting the code after this doesn't change anything.

PHP:
        elseif (
            $userId
            && $userId != $visitor->user_id
            && !$charge->Purchases->offsetExists($visitor->user_id)
        ) {
            return '


And pasting it after this makes the styling work but not the button. Button returns not clickable.
 
Last edited:

BattleKing

Spirit of darkness
Staff member
Administrator
Moderator
+Lifetime VIP+
S.V.I.P Member
Collaborate
Registered
Joined
May 24, 2020
Messages
3,529
Points
523

Reputation:

PHP:
        if (!$visitor->user_id)
        {

Pasting the code after this doesn't change anything.

PHP:
        elseif (
            $userId
            && $userId != $visitor->user_id
            && !$charge->Purchases->offsetExists($visitor->user_id)
        ) {
            return '


And pasting it after this makes the styling work but not the button. Button returns not clickable.
2TapIt works

Blok.png
 

juabo10

Well-known member
Registered
Joined
Aug 20, 2020
Messages
91
Points
28

Reputation:

Dude this function looks great for Resources section, for example: "This resource has been locked. You can unlock it with 2 credits".
How could I do it? Would someone be kind to share a guide?
 

Roland

Well-known member
Registered
Joined
Sep 19, 2022
Messages
89
Points
8

Reputation:

Dude this function looks great for Resources section, for example: "This resource has been locked. You can unlock it with 2 credits".
How could I do it? Would someone be kind to share a guide?
juabo10good idea?

@BattleKing
 
View previous replies…

BattleKing

Spirit of darkness
Staff member
Administrator
Moderator
+Lifetime VIP+
S.V.I.P Member
Collaborate
Registered
Joined
May 24, 2020
Messages
3,529
Points
523

Reputation:

Thank you dude, we will wait :)
juabo10So it works, but looks ugly because I do not have the time to bring it into a nice CSS look and feel

Blok.png


I have installed
Blok.png


Thats the code I changed to:
PHP:
    protected static function renderButtonForUser(int $userId, \DBTech\Credits\Entity\Charge $charge): ?string
    {
        $visitor = \XF::visitor();

        if (!$visitor->user_id)
        {
            return '
                <div style="display: flex;border-style: solid;border-color: blue;color: #4DA9F4;background-color: rgba(    46, 61, 150, 0.15);align-items: center !important;">
                    <span>Click any button to proceed</span>
                        <span style="margin-left: auto !important;">
                            <input type="button" style="float:right!important" class="button" value="' . \XF::phrase('dbtech_credits_costs_x_y', [
                            'param1' => $charge->Currency->getFormattedValue($charge->cost),
                            'param2' => $charge->Currency->title
                        ]) . '" />
                        </span>
                    </span>
                </div>
            ';
        }
        elseif (
            $userId
            && $userId != $visitor->user_id
            && !$charge->Purchases->offsetExists($visitor->user_id)
        ) {
            return '
                <div style="display: flex;border-style: solid;border-color: blue;color: #4DA9F4;background-color: rgba(    46, 61, 150, 0.15);align-items: center !important;">
                    <span>Click any button to proceed</span>
                        <span style="margin-left: auto !important;">
                            <input
                                type="button"
                                class="button"
                                data-xf-click="overlay"
                                data-href="' . \XF::app()->router('public')->buildLink('dbtech-credits/currency/buy-content', $charge->Currency, ['content_type' => $charge->content_type, 'content_id' => $charge->content_id, 'content_hash' => $charge->content_hash]) . '"
                                value="' . \XF::phrase('dbtech_credits_view_for_x_y', [
                            'param1' => $charge->Currency->getFormattedValue($charge->cost),
                            'param2' => $charge->Currency->title
                        ]) . '"
                            />
                        </span>
                    </span>
                </div>
            ';
        }

        return null;
    }

If someone get a better result and formatting, please post that
 

juabo10

Well-known member
Registered
Joined
Aug 20, 2020
Messages
91
Points
28

Reputation:

Hello,
Can anyone tell me how can hide "Richest Users" from events tab please?
I tried many times, but can't :(
imagen.png


Regards!
 

BattleKing

Spirit of darkness
Staff member
Administrator
Moderator
+Lifetime VIP+
S.V.I.P Member
Collaborate
Registered
Joined
May 24, 2020
Messages
3,529
Points
523

Reputation:

Hello,
Can anyone tell me how can hide "Richest Users" from events tab please?
I tried many times, but can't :(
imagen.png


Regards!
juabo10You can use a template modification to remove that, or show it only to specific groups
 

juabo10

Well-known member
Registered
Joined
Aug 20, 2020
Messages
91
Points
28

Reputation:

You can use a template modification to remove that, or show it only to specific groups
BattleKingI have reviewed the style properties and I did not find the option that allows me to deactivate it, or is it that it will be necessary to modify it at the code level?
 
Top