DragonByte Credits: Change Charge BBCode Styling

BattleKing

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

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?

2TapDid you faked that screenshot or where did you took this from
 

2Tap

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

Reputation:

View previous replies…

juabo10

Well-known member
Registered
Joined
Aug 20, 2020
Messages
72
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…

juabo10

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

Reputation:

So it works, but looks ugly because I do not have the time to bring it into a nice CSS look and feel

View attachment 31363

I have installed
View attachment 31364

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
BattleKingThanks for taking the time, I think there was a misunderstanding. 😔
The download button should be modified and show the following message: 10 Credit for download

It is not related to the forum.
Although perhaps this modification will like others.
 

BattleKing

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

Reputation:

Thanks for taking the time, I think there was a misunderstanding. 😔
The download button should be modified and show the following message: 10 Credit for download

It is not related to the forum.
Although perhaps this modification will like others.
juabo10
Blok.png

like that

If you want to change the content of the button this can be done via modify the phrase
Blok.png


Blok.png



Or do you mean the download button of attachments of a post, but this is not what has been shown in the screenshot
 

juabo10

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

Reputation:

View attachment 31367
like that

If you want to change the content of the button this can be done via modify the phrase
View attachment 31368

View attachment 31369


Or do you mean the download button of attachments of a post, but this is not what has been shown in the screenshot
BattleKingI am referring to the download from the Resources section, to download it is necessary to have Credits, a message that says the cost of credit to download is what I am looking for.
If the user presses the download button without having credits, he will be redirected to an error message insufficient credits.
 

juabo10

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

Reputation:

@BattleKing This is my code from xfrm_resource_wrapper_macros template

Code:
                                <span class="button button--wrap is-disabled">{{ phrase('xfrm_no_permission_to_download') }}</span>
                            </xf:if>
                        </div>
                    <xf:elseif is="$resource.isExternalPurchasable()" />
                        <div class="p-title-pageAction">
                            <xf:if is="$resource.canDownload()">
                                <xf:button href="{$resource.external_purchase_url}" class="button--cta" icon="purchase" target="_blank" rel="noopener">
                                    {{ phrase('xfrm_buy_for_x', {'price': $resource.price|currency($resource.currency)}) }}
                                </xf:button>
                            <xf:else />
                                <span class="button button--wrap is-disabled">{{ phrase('xfrm_no_permission_to_buy_price_x', {'price': $resource.price|currency($resource.currency)}) }}</span>
                            </xf:if>

I think it is in this code where the modifications should be made.

and in extra.less must add the design and color code.
 

BattleKing

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

Reputation:

@BattleKing This is my code from xfrm_resource_wrapper_macros template

Code:
                                <span class="button button--wrap is-disabled">{{ phrase('xfrm_no_permission_to_download') }}</span>
                            </xf:if>
                        </div>
                    <xf:elseif is="$resource.isExternalPurchasable()" />
                        <div class="p-title-pageAction">
                            <xf:if is="$resource.canDownload()">
                                <xf:button href="{$resource.external_purchase_url}" class="button--cta" icon="purchase" target="_blank" rel="noopener">
                                    {{ phrase('xfrm_buy_for_x', {'price': $resource.price|currency($resource.currency)}) }}
                                </xf:button>
                            <xf:else />
                                <span class="button button--wrap is-disabled">{{ phrase('xfrm_no_permission_to_buy_price_x', {'price': $resource.price|currency($resource.currency)}) }}</span>
                            </xf:if>

I think it is in this code where the modifications should be made.

and in extra.less must add the design and color code.
juabo10You mean like this:

Blok.png
 
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,519
Points
523

Reputation:

Yes, that is what i'm looking for :)
But the Download button should be locked when you don't have enough credit, otherwise it might cause confusion.
juabo10An addon is required for that which need to be developed
 

BattleKing

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

Reputation:

oh i see, but how can add that message? "You can download this resource for 20 Credits" ?
Can you share de code pls?
juabo10It will not help, because the credits are hard coded in that, if that help I can share it.
 

leanndamiann1

Well-known member
Registered
Joined
Apr 22, 2021
Messages
190
Points
28

Reputation:

Once you show me the content, can it be displayed like this?

4.png
 

BattleKing

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

Reputation:

View previous replies…

fakemasked

Well-known member
Registered
Joined
Apr 10, 2023
Messages
77
Points
8

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,519
Points
523

Reputation:

I understand but those codes are from charge.ph of the dragon credits addon, and I don't use the CHARGE tag, I use the HIDE tag of the addon [XenConcept] Hide BBCode] maybe it can also be edited to put some text when it unlocks the content.

For example I want to add some text above for when it is unlocked
View attachment 34761
I leave you an example maybe you understand
leanndamiann1But gentlemen what is the title of that thread? It was a question for DBTech Credits Charge box, not about hide bbcode.

Open new thread for hide question. This is much more easy than the credit one
 

ipreallyfire

New member
Registered
Joined
Nov 18, 2021
Messages
2
Points
13

Reputation:

Hello to everyone! Did someone one find the way to make "charge" bb code a disposable?
Like it is able to see only for first one who paid first?
 
Last edited:

Sagex

Well-known member
Registered
Joined
Sep 10, 2021
Messages
59
Points
28

Reputation:

So has anyone found a way to make that?
 

fakemasked

Well-known member
Registered
Joined
Apr 10, 2023
Messages
77
Points
8

Reputation:

fakemasked

Well-known member
Registered
Joined
Apr 10, 2023
Messages
77
Points
8

Reputation:

if you get it, then please share it with the users
if not I will have a look into it later
BattleKingi only got it for locked content not for unlocked one 🥲 just tell me which template or line i have to edit and i will do it and post it full code here for both
 
Last edited:
Top