paperweight Posted August 2, 2012 Share Posted August 2, 2012 I am really frustrated trying to figure out how to combine 2 templates in my theme into one. I want to put the list of support tickets found on supportticketslist.tpl at the bottom of the page of supportticketsubmit-stepone.tpl. When I copy the content of supportticketslist.tpl and paste it into supportticketsubmit-stepone.tpl, almost all the code displays fine. However, the list of tickets is not there. Instead it says "No Records Found" even though there are tickets available! So I think the atabase is not being queried correctly when I remove code from supportticketslist.tpl and place it elsewhere, correct? Is there something I am missing that I should wrap around this code to make it work? 0 Quote Link to comment Share on other sites More sharing options...
criat Posted November 10, 2013 Share Posted November 10, 2013 Yeah, I have the exact same problem +1 0 Quote Link to comment Share on other sites More sharing options...
othellotech Posted November 11, 2013 Share Posted November 11, 2013 So I think the atabase is not being queried correctly when I remove code from supportticketslist.tpl and place it elsewhere, correct? You need to do your own query - e.g. select * from tbltickets where status='Open' 0 Quote Link to comment Share on other sites More sharing options...
Kian Posted November 11, 2013 Share Posted November 11, 2013 Yep, you can't pretend to mashup scripts, templates and queries It doesn't work like this. You have to create a new page with your own queries, scripts and layout. It's all written here: Creating_Pages. 0 Quote Link to comment Share on other sites More sharing options...
criat Posted November 11, 2013 Share Posted November 11, 2013 But why there's this then? How to define template variables ($ca->assign)And how to set the template to use and then output it There's no way to use something like $ca->assign('ticket', $ticket); then output it? (Tried this, didn't work. Maybe something similar?) 0 Quote Link to comment Share on other sites More sharing options...
Kian Posted November 11, 2013 Share Posted November 11, 2013 Are you trying to add $ca->assign('ticket', $ticket); inside the .tpl file? This piece of code is not Smarty, it's PHP in OOP. You should use {php}{/php} tag but i'm not sure of what you are trying to do with this. Can you please post the code that you are using now? 0 Quote Link to comment Share on other sites More sharing options...
criat Posted November 12, 2013 Share Posted November 12, 2013 open-tickets.php <?php define("CLIENTAREA",false); require("init.php"); include("includes/functions.php"); $ca = new WHMCS_ClientArea(); $ca->setPageTitle($whmcs->get_lang('opentiketstitle')); $ca->addToBreadCrumb('index.php',$whmcs->get_lang('globalsystemname')); $ca->addToBreadCrumb('support-tickets.php',$whmcs->get_lang('opentiketstitle')); $ca->initPage(); $ca->requireLogin(); // Uncomment this line to require a login to access this page $ca->setTemplate('open-tickets'); $ca->output(); ?> open-tickets.tpl <h1>{$LANG.ticketsabertostitle}</h1> <div class="table_title opentickets" style="margin-top:20px;"> <span class="icon"></span> <a class="btn btn-primary pull-right" href="submitticket.php">{$LANG.opennewticket}</a> <h3><strong>{$clientsstats.numactivetickets}</strong> {$LANG.supportticketsopentickets}</h3> </div> <table class="table table-striped table-framed table-centered no-more-tables"> <thead> <tr> <th><a href="supporttickets.php?orderby=date">{$LANG.supportticketsdate}</a></th> <th><a href="supporttickets.php?orderby=dept">{$LANG.supportticketsdepartment}</a></th> <th><a href="supporttickets.php?orderby=subject">{$LANG.supportticketssubject}</a></th> <th><a href="supporttickets.php?orderby=subject">{$LANG.supportticketsstatus}</a></th> <th class="headerSortdesc"><a href="supporttickets.php?orderby=lastreply">{$LANG.supportticketsticketlastupdated}</a></th> <th></th> </tr> </thead> <tbody> {foreach from=$tickets item=ticket} <tr> <td data-title="{$LANG.supportticketsdate}">{$ticket.date}</td> <td data-title="{$LANG.supportticketsdepartment}">{$ticket.department}</td> <td data-title="{$LANG.supportticketssubject}"><div align="left"><img src="images/article.gif" alt="Ticket" border="0" /> <a href="viewticket.php?tid={$ticket.tid}&c={$ticket.c}">{if $ticket.unread}<strong>{/if}#{$ticket.tid} - {$ticket.subject}{if $ticket.unread}</strong>{/if}</a></div></td> <td data-title="{$LANG.supportticketsstatus}">{$ticket.status}</td> <td data-title="{$LANG.supportticketsticketlastupdated}">{$ticket.lastreply}</td> <td class="last textcenter"><a href="viewticket.php?tid={$ticket.tid}&c={$ticket.c}" class="btn btn-inverse">{$LANG.supportticketsviewticket}</a></td> </tr> {foreachelse} <tr> <td colspan="6" class="textcenter">{$LANG.supportticketsnoneopen}</td> </tr> {/foreach} </tbody> </table> Output: 0 Quote Link to comment Share on other sites More sharing options...
Kian Posted November 12, 2013 Share Posted November 12, 2013 It doesn't work because you are trying to load a non-existing variable. When you reference to {$ticket.subject} inside your open-tickets.tpl, Smarty will try to get this variable from open-tickets.php. Here i can see that there's just the framework and nothing more. Take a look at this example and read comments. open-tickets.php <?php define("CLIENTAREA",false); require("init.php"); include("includes/functions.php"); $ca = new WHMCS_ClientArea(); $ca->setPageTitle($whmcs->get_lang('opentiketstitle')); $ca->addToBreadCrumb('index.php',$whmcs->get_lang('globalsystemname')); $ca->addToBreadCrumb('support-tickets.php',$whmcs->get_lang('opentiketstitle')); $ca->initPage(); $ca->requireLogin(); // I don't know the values that you are trying to get from database so change this query accordingly $result = mysql_query("SELECT name, lastname FROM clients WHERE clientid='1'"); $row = mysql_fetch_array($result); # Let's say that $row["name"] is equal to "James" and $row["lastname"] is "Bond" // If the result is not empty i create 'name' and 'lastname' Smarty value if($row) { $ca->assign('name', $row["name"]); # {$name} contains "James" $ca->assign('lastname', $row["lastname"]); # {$lastname} contains "Bond" } $ca->setTemplate('open-tickets'); $ca->output(); ?> open-tickets.tpl <p>Hey baby... i'm {$name}, {$name} {$lastname}</p> It prints out "Hey baby... i'm James, James Bond". Now 3 notes about this script: First of all the MySQL API (aka library). In my example i was using MySQL library just because it's faster to write You should use PDO (Prepared Statements) or MySQLi because of this reason. You could also use SQL_Helper_Functions of WHMCS but they're not confortable to use. About arrays. In the example i assigned two separate values ({$name} and {$lastname}) but you can still use arrays. With $ca->assign('clientdetails', $row) for example you can print "James" with {$clientdetails.name} and "Bond" with {$clientdetails.lastname}. I hope that it's clear enough. Of course you can use while(); foreach(); (...) loops and $ca->assign(); inside the iteration. I know that this argument could be tricky especially if you are not a developer but if you are it's easy. 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.