Jump to content

clientarea home panel to display domains


cdeese8

Recommended Posts

How do I create a clientarea home panel that displays domains?  It would be cool if I could just copy / paste table found on example.com/clientarea.php?action=domains ... OR something more simple that displays UPTO 10 domain name that each have a manage button to redirects user to the example.com/clientarea.php?action=domaindetails&id=999 page.

I think it would be cool to save client a couple of clicks, but really just display everything on clientarea home panel.

There is already a home panel that shows "Domains Expiring Soon" on clientarea home that redirects to the example.com/cart.php?gid=renewals page. I believe is getting data from cart template file domainrenewals.tpl. I brushed over the docs here https://docs.whmcs.com/Working_With_Client_Area_Home_Page_Panels and I also scoured over a bunch of community topics that involve hooks but nothing I tried last night worked. I only spent 90 minutes but still... dang!

Before I went to bed last night, I started playing with hooks and I copy / pasted code scattered all over these forums but I kept getting broken website error like "oops, something isn't right" and deleted everything.

https://www.google.com/search?ei=_i8qXtvgKqe-ggfn7Jpo&q=site%3Awhmcs.community+home+panel&oq=site%3Awhmcs.community+home+panel

When I log into the database using Adminer, I see the table and data that I desire too.

  • tbldomains > domains
  • tbldomains > newduedate (which I think expire date)
Link to comment
Share on other sites

12 hours ago, cdeese8 said:

It would be cool if I could just copy / paste table found on example.com/clientarea.php?action=domains ...

oh if only it was as simple as that. 🙂

12 hours ago, cdeese8 said:

OR something more simple that displays UPTO 10 domain name that each have a manage button to redirects user to the example.com/clientarea.php?action=domaindetails&id=999 page.

something along the lines of below?

JJrmps5.png

14 hours ago, cdeese8 said:

There is already a home panel that shows "Domains Expiring Soon" on clientarea home that redirects to the example.com/cart.php?gid=renewals page. I believe is getting data from cart template file domainrenewals.tpl.

it won't be getting the data from a template - it will be pulling the information from the database.

15 hours ago, cdeese8 said:

I brushed over the docs here https://docs.whmcs.com/Working_With_Client_Area_Home_Page_Panels and I also scoured over a bunch of community topics that involve hooks but nothing I tried last night worked. I only spent 90 minutes but still... dang! 

almost certainly I will have posted similar hooks to the one required for the above panel - basically you're just foreach looping through your results array.

you will also have to determine what you want to output in the content... e.g. domain & manage button; domain, NDD and status etc.. for the quick example above, I just kept it vaguely similar to the Services panel layout, where each row is linked to the appropriate domain details page.

Link to comment
Share on other sites

I'm  onto you dude! It's like you are holding a fishing pole with some bait and I'm  trying to eat that bait. hahahaha

Alright, well if you are telling me you already wrote a home panel hook to display domains, than I just gotta dig into your post history replies, find the code and altercate it. Let's see what I can come up with and I'll report back here. I too, will determine what exact I want to output.

talk to you soon!

😎

Link to comment
Share on other sites

How do I display domain name for each child? It's the {$domains.domain} smarty variable I believe.

I think I already had something similar that I was able to build off of.... but no results.

  • *display UPTO 4 domains
    • i don't think i have this working, i tried to test on client with 5 domains, but only 1 child is being loaded. perhaps the scrollbar like from your image is best, and display just 4.
  • sort by domain name
  • include "newduedate " into panel
  • open link in new window

I'm  getting stuck on the $clientdomain AND .fromMySQLDate part of the hook, still don't know what they mean.  Also, I don't think I'm  loading the table data newduedate into this hook...

<?php

# Made with help of Honored Contributor brian!

// https://whmcs.community/topic/292268-email-history-homepage-panel/
// https://forums.whmcs.com/showthread.php?127034-home-page-panel-add-array-title-and-target-to-href
// https://developers.whmcs.com/hooks/hook-index/
// http://docs.whmcs.com/Working_With_Client_Area_Home_Page_Panels
// https://developers.whmcs.com/hooks-reference/client-area-interface/#clientareahomepagepanels

use Illuminate\Database\Capsule\Manager as Capsule;
use WHMCS\View\Menu\Item;

add_hook('ClientAreaHomepagePanels', 1, function (Item $homePagePanels)
{
    $client = Menu::context('client');
    $clientdomain = Capsule::table('tbldomains')->where('userid', $client->id)->select('id','domain')->orderBy('domain','desc')->limit(4)->get();

    if (count($clientdomain)) {
        $homePagePanels->addChild('Manage Domains', array(
        'label' => 'Domains', // panel title name
        'icon' => '',
        'order' => 0,
        'extras' => array( // panel title button
            'color' => '',
            'btn-link' => 'clientarea.php?action=domaindetails',
            'btn-text' => Lang::trans('managedomain'),
            'btn-icon' => '',
        ),
        ));
        // foreach ($clientdomain as $key => $child){
        //     $homePagePanels->getChild('Manage Domains')
        //                     ->addChild($child->domains)->setUri('clientarea.php?action=domaindetails&id='.$child->id)->setAttribute('target','_blank');
        // }
        // uncomment above / below to "load domain newduedate"       
        foreach ($clientemails as $key => $child){
         $homePagePanels->getChild('Manage Domains')
                         ->addChild($key)->setLabel('<span class="xyz">Domain: '.fromMySQLDate($child->newduedate,true,false).'</span>'.$child->domains)->setUri('clientarea.php?action=domaindetails&id='.$child->id)->setAttribute('target','_self');
        }
    }
});

 

Edited by cdeese8
found a way to kinda make it work ...
Link to comment
Share on other sites

15 hours ago, cdeese8 said:

I'm  onto you dude! It's like you are holding a fishing pole with some bait and I'm  trying to eat that bait. hahahaha

except that I gave you the whole fishing kit to play with. 🐟 ☺️

14 hours ago, cdeese8 said:

It's the {$domains.domain} smarty variable I believe.

for a capsule query, you would normally use $child->domain (depending on what you've called the $child part in the foreach loop).

14 hours ago, cdeese8 said:

i don't think i have this working, i tried to test on client with 5 domains, but only 1 child is being loaded. perhaps the scrollbar like from your image is best, and display just 4.

always remember to choose a client that has more than one domain!

too often i've chosen a test client that doesn't have the services/domains that i'm trying to output, and i'm then scratching my head, looking at the code knowing that it's right and it should work. smiley-bangheadonwall-yellow.gif

15 hours ago, cdeese8 said:

include "newduedate " into panel

it's not listed in the select part of your query, so it won't be part of the results array until you include it there.

15 hours ago, cdeese8 said:

I'm  getting stuck on the $clientdomain AND .fromMySQLDate part of the hook, still don't know what they mean.

the query itself is fine - though as I said, you're probably missing the NDD from the select.

that foreach really needs to be foreach ($clientdomain as $key => $child){  if you're going to loop through the results array correctly.

https://developers.whmcs.com/advanced/date-functions/

Quote

 * @param string $datetimestamp The MySQL Date/Timestamp value
 * @param bool $includeTime Pass true to include the time in the result
 * @param bool $applyClientDateFormat Set true to apply Localisation > Client Date Format
15 hours ago, cdeese8 said:

Also, I don't think I'm  loading the table data newduedate into this hook...

see above with regards to the select values in the query.

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.

×
×
  • 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