cdeese8 Posted March 5, 2019 Share Posted March 5, 2019 How do I display client tickets tablelist (like in clientarea home panel) on knowledgebase.tpl or static page? When i explored the /feed/ folder, it doesn't look like anything relevant is there - perhaps data feeds are not available option (https://docs.whmcs.com/Data_Feeds). So would I make a hook? That makese sense. I tried to make an includes/hook/display-tickets-help.php file and copy / pasted things I gathered on forums but that's not good. I get oops error and break site. Stock theme on WHMCS 7.4.* - this is the hook that is giving me trouble: https://pastebin.com/r1wYxYE7 https://developers.whmcs.com/hooks/hook-index/ https://whmcs.community/topic/284977-hook-to-display-todo-list-to-public-or-logged-in-clients/ tried changing 1 to 0 at the very bottom "add_hook("ClientAreaPage", 0, "display_help_tickets");" (don't think it matters though) Thanks for looking this over if you are thinking about helping out. :) 0 Quote Link to comment Share on other sites More sharing options...
steven99 Posted March 5, 2019 Share Posted March 5, 2019 First do any development in a development environment and not production site. Second, enable the "display errors" under Setup menu -> general settings -> other tab. That will show you the exact error. Looking over the code real quick, I suspect it is the old select_query and that needs to be changed to use the capsule style. Then use clientareapageknowledgebase hook and return the tickets as an array and output via smarty template. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted March 6, 2019 Share Posted March 6, 2019 13 hours ago, cdeese8 said: How do I display client tickets tablelist (like in clientarea home panel) on knowledgebase.tpl or static page? as steven says, hook -> tickets array -> output... obviously, the client would need to be logged in for this to be a viable option... 14 hours ago, cdeese8 said: When i explored the /feed/ folder, it doesn't look like anything relevant is there - perhaps data feeds are not available option (https://docs.whmcs.com/Data_Feeds). so write your own! 🙂 if this was going to be outputted outside of WHMCS, then a feed would be an option... if you were doing this in WHMCS, using a hook would be a better solution that using a feed IMO. but as a general principle, can you effectively output a homepagepanel as a data feed ? absolutely yes... you have to recreate everything (array/layout/css), but it can be done (i've done it for paying clients) ... whether it's worth doing for support tickets, i'm not sure - certainly not if it's internal to WHMCS. 14 hours ago, cdeese8 said: So would I make a hook? That makes sense. I tried to make an includes/hook/display-tickets-help.php file and copy / pasted things I gathered on forums but that's not good. I get oops error and break site. then you should have posted your code... 14 hours ago, cdeese8 said: Stock theme on WHMCS 7.4.* - this is the hook that is giving me trouble: https://pastebin.com/r1wYxYE7 but the URL in that code takes you to the thread you posted, which includes a capsule hook to do this for todo items... all you really need to do is change the table that you're querying... and as steven says, those queries are out of date for recent versions of WHMCS and PHP. a better example as a starting point for you might be the basic capsule hook I posted 3 years ago that got the users support tickets from the database and returned a Smarty variable {$displaysupporttickets} that you could use in your template to output the results. <?php use Illuminate\Database\Capsule\Manager as Capsule; function hook_displaysupporttickets($vars){ $client = Menu::context('client'); $output = ""; $tickets = Capsule::table('tbltickets')->where('userid',$client->id)->orderBy('date','desc')->take(6)->get(); foreach ($tickets as $ticket) { $output .= '<p><a href="viewticket.php?tid='.$ticket->tid.'">'.$ticket->title.'</a><span>'.$ticket->department.'</span><span>'.$ticket->tid.'</span><span>'.fromMySQLDate($ticket->date).'</span></p>'; } return array("displaysupporttickets" => $output); } add_hook("ClientAreaPageKnowledgebase", 1, "hook_displaysupporttickets"); now that code returns the output in a very basic layout - but there's nothing to stop you adding the homepagepanel layout code (copying code from clientareahome.tpl that outputs the panels, stripping out the unnecessary Smarty code, hardcoding when required and using language strings), or a tablelist, inside the hook, or just returning the array and doing the outputting in the template - whatever path you choose for what you want to do, you're going to use a hook and a template edit - it's just a case of how you want to split the balance and which you find easier to do. you could also use the GetTickets API to get the ticket data, but personally I always prefer to query directly as i'm then not reliant on WHMCS changing how an API function works/returns, not documenting those changes, hence screwing up the solution and having to spend longer trying to debug what's going on with the undocumented change(s)... at least with Laravel, all the changes will be well documented and simple to update... i've been bitten once too many times using the API for simple things like this and so avoid it unless it's not practical to write a query - just a personal choice. 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.