snake Posted October 26, 2016 Share Posted October 26, 2016 disclaimer: I am not a PHP developer, I have put this together just by looking at other people's code and the docs. I have a hook that sends out an email to all dept staff whenever a note is added to a ticket. It is working fine, except for the LINK to the ticket, I am using this. "ticket_link" => "http://{$whmcs_admin_url}supporttickets.php?action=view&id={$tid}" but {$whmcs_admin_url} doesn't seem to exist in this context, I found this in the email templates, how do I access this value froma hook? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted October 27, 2016 Share Posted October 27, 2016 my first thought when I saw that code was... why not just hardcode the URL?? i'm working on the assumption that you already know your own admin URL! second thought is wondering why you were trying to use Smarty variables in that way in a hook - just because a variable exists in an email template, doesn't mean that it's accessible elsewhere. if it were me, i'd just hardcode the URL in the variable and then see if id passes the correct ticket ID value. 0 Quote Link to comment Share on other sites More sharing options...
snake Posted October 27, 2016 Author Share Posted October 27, 2016 my first thought when I saw that code was... why not just hardcode the URL?? i'm working on the assumption that you already know your own admin URL! I could do that, but that would be lazy coding, and I wanted to put the hook up on the marketplace for others to use, and doing that would mean the code won't work anywhere else without manually changing the code. second thought is wondering why you were trying to use Smarty variables in that way in a hook - just because a variable exists in an email template, doesn't mean that it's accessible elsewhere. Go back and read the very first line of my first post. if it were me, i'd just hardcode the URL in the variable and then see if id passes the correct ticket ID value. While I may not be a PHP developer, but I do have a background in programming on other languages, and I have never been one for lazy coding and bad practices, see my answer above, so I would rather do it properly and start as I mean to go on. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted October 28, 2016 Share Posted October 28, 2016 I could do that, but that would be lazy coding, and I wanted to put the hook up on the marketplace for others to use, and doing that would mean the code won't work anywhere else without manually changing the code.Go back and read the very first line of my first post. aaah I took from the first line that this was for personal use and therefore couldn't understand why you had ignored the obvious solution... now it makes sense! While I may not be a PHP developer, but I do have a background in programming on other languages, and I have never been one for lazy coding and bad practices, see my answer above, so I would rather do it properly and start as I mean to go on. by getting help with the basic coding. outside of the email templates, I don't believe that $whmcs_admin_url exists in its own right - the best that you can do is recreate it from it's component parts... global $CONFIG, $customadminpath; "ticket_link" => $CONFIG['SystemURL'].'/'.$customadminpath.'/supporttickets.php?action=view&id='.$vars['ticketid']; i'm assuming you have access to ticketid in the hook, but that might depend on which one you're using - otherwise, it may need to looked up. I look forward to receiving a share of the profits. 0 Quote Link to comment Share on other sites More sharing options...
snake Posted November 9, 2016 Author Share Posted November 9, 2016 I just did it in the email template instead DOH!!! that was the obvious solution. aaah I took from the first line that this was for personal use and therefore couldn't understand why you had ignored the obvious solution... now it makes sense! by getting help with the basic coding. outside of the email templates, I don't believe that $whmcs_admin_url exists in its own right - the best that you can do is recreate it from it's component parts... global $CONFIG, $customadminpath; "ticket_link" => $CONFIG['SystemURL'].'/'.$customadminpath.'/supporttickets.php?action=view&id='.$vars['ticketid']; i'm assuming you have access to ticketid in the hook, but that might depend on which one you're using - otherwise, it may need to looked up. I look forward to receiving a share of the profits. 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.