Jump to content

how can add a button in clientareaproductdetails


Anders

Recommended Posts

Hi guys,

i am trying to add a button in clientareaproductdetails please see screenshot.

i tried in mytheme/clientareaproductdetails.tpl also tried in \modules\servers\cpanel\templates/overview.tpl

i cleared cache but nothing showing up.

this is in overview.tpl on line 14 i added this but is not working, i did he same in /clientareaproductdetails.tpl any ideas?

 <!--<a href="http://{$domain}" class="btn btn-default btn-sm" target="_blank">{$LANG.visitwebsite}</a>-->
            <a href="myownurl" class="btn btn-default btn-sm" target="_blank">{$LANG.mylang}</a>

<div class="col-md-6">

        <div class="panel panel-default" id="cPanelPackagePanel">
            <div class="panel-heading">
                <h3 class="panel-title">{$LANG.cPanel.packageDomain}</h3>
            </div>
            <div class="panel-body text-center">

                <div class="cpanel-package-details">
                    <em>{$groupname}</em>
                    <h4 style="margin:0;">{$product}</h4>
                    <a href="http://{$domain}" target="_blank">www.{$domain}</a>
                </div>

                <p>
                    <!--<a href="http://{$domain}" class="btn btn-default btn-sm" target="_blank">{$LANG.visitwebsite}</a>-->
                    <a href="myownurl" class="btn btn-default btn-sm" target="_blank">{$LANG.mylang}</a>
                    {if $domainId}
                        <a href="clientarea.php?action=domaindetails&id={$domainId}" class="btn btn-success btn-sm" target="_blank">{$LANG.managedomain}</a>
                    {/if}
                    <input type="button" onclick="popupWindow('whois.php?domain={$domain}','whois',650,420);return false;" value="{$LANG.whoisinfo}" class="btn btn-info btn-sm" />
                </p>

            </div>
        </div>

        {if $availableAddonProducts}
            <div class="panel panel-default" id="cPanelExtrasPurchasePanel">
                <div class="panel-heading">
                    <h3 class="panel-title">{$LANG.cPanel.addonsExtras}</h3>
                </div>
                <div class="panel-body text-center">

                    <form method="post" action="cart.php?a=add" class="form-inline">
                        <input type="hidden" name="serviceid" value="{$serviceid}" />
                        <select name="aid" class="form-control input-sm">
                        {foreach $availableAddonProducts as $addonId => $addonName}
                            <option value="{$addonId}">{$addonName}</option>
                        {/foreach}
                        </select>
                        <button type="submit" class="btn btn-default btn-sm">
                            <i class="fas fa-shopping-cart"></i>
                            {$LANG.cPanel.purchaseActivate}
                        </button>
                    </form>

                </div>
            </div>
        {/if}

    </div>

 

2020-03-16_22-02-43.jpg

Link to comment
Share on other sites

15 hours ago, Anders said:

this is in overview.tpl on line 14 i added this but is not working, i did he same in /clientareaproductdetails.tpl any ideas?

if it's a cPanel product, then it shopuld be the overview template; if it's using another module, then there may be separate templates available - otherwise, it would be clientareaproductdetails.tpl.

for example, if I tweak overview.tpl to add another button, and I view a cPanel service in productdetails, I see this...

BP8ahli.png

                <p>
                    <a href="http://{$domain}" class="btn btn-default btn-sm" target="_blank">{$LANG.visitwebsite}</a>
                    <a href="myownurl" class="btn btn-default btn-sm" target="_blank">Button</a> 
                    {if $domainId}
                        <a href="clientarea.php?action=domaindetails&id={$domainId}" class="btn btn-success btn-sm" target="_blank">{$LANG.managedomain}</a>
                    {/if}
                    <input type="button" onclick="popupWindow('whois.php?domain={$domain}','whois',650,420);return false;" value="{$LANG.whoisinfo}" class="btn btn-info btn-sm" />
                </p>

ignore that i've hardcoded the button text rather than using a Language string, but it was quicker...

also, you shouldn't really edit overview.tpl as it will get overwritten during a WHMCS update - you can copy the template(s) to your active template folder and they shouldn't (theoretically!) get overwritten - though you'd have to remember to check after an update to see if they've been any template changes.

https://docs.whmcs.com/Working_with_Module_Templates

Quote

For example, in the case of the provisioning module "cpanel", /modules/servers/cpanel/overview.tpl could be customised by creating the following template file: /templates/yourtemplatename/modules/servers/cpanel/overview.tpl

you could inject a button into there with a hook, but then it gets real complicated if you wanted to also remove an existing button - especially as WHMCS has an aversion to correct CSS use in it's code.

bYA0UCR.png

so it's easier to stick with editing these templates for now!

Link to comment
Share on other sites

Thx again for your advice :)

i made a folder in template file see screenshot and i have added the code and still no show of the button, any ideas?

  <p>
                    <a href="http://{$domain}" class="btn btn-default btn-sm" target="_blank">{$LANG.visitwebsite}</a>
                    <a href="index.php?m=websitebuilder" target="_blank">WEBSITEBUILDER</a>
                    {if $domainId}
                        <a href="clientarea.php?action=domaindetails&id={$domainId}" class="btn btn-success btn-sm" target="_blank">{$LANG.managedomain}</a>
                    {/if}
                    <input type="button" onclick="popupWindow('whois.php?domain={$domain}','whois',650,420);return false;" value="{$LANG.whoisinfo}" class="btn btn-info btn-sm" />
                </p>

 

2020-03-17_14-23-58.jpg

Link to comment
Share on other sites

6 minutes ago, Anders said:

oh i see is a module installed called panel extended. 

by ModuleGardens ?

6 minutes ago, Anders said:

is it not possible to add a button with that module? 

I assume there is a /templates folder with the /modules/servers/cpanelExtended/ folder ? if so, then there must be a similar template in there.

as I said, you could do it with a hook, but it might be worth asking MG about editing the template and the implications of what happens if you update their module.

Link to comment
Share on other sites

  • 2 weeks later...

Hello Brian,

i am using your amazing hook see below  but for some reason it does not add my text button on ID 4
it add it on all the others as you also can see i use ID 4 a copy from my whmcs (https://mysite.com/whmcs/cart.php?a=add&pid=4)

any ideas is so weird

<?php

add_hook('ClientAreaProductDetailsOutput', 1, function($service) {
    $serviceID = $service['service']->Id;
    $productID = $service['service']->packageId;
    $groupID = $service['service']->product->productGroupId;
    if (in_array($productID, array('2','3','4'))) {
        $output .= '<div class="alert" role="alert"><div class="row"><div class="col-sm-1"></div>
                                <div class="text-center"><a type="button" href="index.php?m=stiew12" style="padding: 5px 40px; color:#fff;" class="btn btn-primary btn-lg" target="_blank"><i class="fa fa-pencil" aria-hidden="true"></i> site</a></div></div></div>';
    }
    if ($output) {
        return $output;
    }
});

 

Link to comment
Share on other sites

  • 1 month later...

Hi Brian,

i wonder if you could help me with this as you are the super pro :)

i use this code below in user area but i wish to disable it for a groupID  (2)and productID (5)  

 

add_hook('ClientAreaHomepage', 1, function($vars) {
	$client = Menu::context('client');
	$activeservices = $client->services->where('domainstatus','=','Active')->count();
	if ($client && $activeservices == 0) {
		return '<div class="text-center"><h3 class="alert alert-info order-confirmation"><a href="#myModal" data-toggle="modal"><strong><i class="fab fa-youtube" aria-hidden="true"> Watch how to get to Website Builder</i></strong></a></h3></div><br />
		<!-- Modal HTML -->
    <div id="myModal" class="modal fade">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title">How to find builder</h4>
                </div>
                <div class="modal-body">
                    <iframe id="cartoonVideo" width="560" height="315" src="#" frameborder="0" allowfullscreen></iframe>
                </div>
            </div>
        </div>
    </div>';
	}
});

warm regards Anders

Link to comment
Share on other sites

4 hours ago, Anders said:

i use this code below in user area but i wish to disable it for a groupID  (2)and productID (5)  

product groups are a problem because the model (and by implication the database table) don't store them... so what you will have to do is get a list of product IDs for that group and then use that list in the conditional statement... because there was a technical issue using wherenotin (don't know if that's a bug), I switched to using capsule and querying the database.

<?php

use WHMCS\Database\Capsule;

add_hook('ClientAreaHomepage', 1, function($vars) {
	$client = Menu::context('client');
	$groupproducts = Capsule::table('tblproducts')->where('gid','2')->pluck('id');
	$activeservices = Capsule::table('tblhosting')->where('userid',$client->id)->where('domainstatus','Active')->where('packageid','<>','5')->whereNotIn('packageid',$groupproducts)->count();
	if ($client && $activeservices == 0) {
		return '<div class="text-center"><h3 class="alert alert-info order-confirmation"><a href="#myModal" data-toggle="modal"><strong><i class="fab fa-youtube" aria-hidden="true"> Watch how to get to Website Builder</i></strong></a></h3></div><br />
		<!-- Modal HTML -->
    <div id="myModal" class="modal fade">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                    <h4 class="modal-title">How to find builder</h4>
                </div>
                <div class="modal-body">
                    <iframe id="cartoonVideo" width="560" height="315" src="#" frameborder="0" allowfullscreen></iframe>
                </div>
            </div>
        </div>
    </div>';
	;
	}
});
Link to comment
Share on other sites

2 minutes ago, Anders said:

one for the moment

then what happens if you use...

$activeservices = Capsule::table('tblhosting')->where('userid',$client->id)->where('domainstatus','Active')->whereNotIn('packageid',[5,x])->count();

change x to the PID of the product in #2

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated