Neklawy Posted June 19, 2018 Share Posted June 19, 2018 Hello, I would like to change the $ticket_url or $ticket_link outputs in support email template from whmcsurl/viewticket.php?tid=2222&c=Pkjr2jgW to the following format whmcsurl/viewticket/2222-Pkjr2jgW I tried replace {&ticket_link} to {$ticket_link|replace:'.php?tid=':'/'|replace:'&c=':'-'} But that is not works Can any one help me for make that via hook? Thanks 0 Quote Link to comment Share on other sites More sharing options...
bellafronte Posted June 19, 2018 Share Posted June 19, 2018 HTACCESS rules you can perform this change =) Try search HTACCESS rules regex! 0 Quote Link to comment Share on other sites More sharing options...
Neklawy Posted June 19, 2018 Author Share Posted June 19, 2018 I already did that URL rewrites using htaccess and the URL format is works with me when request it in browser, But I would to change a base ticket link in Email support template Thanks 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted June 20, 2018 Share Posted June 20, 2018 9 hours ago, Neklawy said: But that is not works But I would to change a base ticket link in Email support template your code in the first post will work fine.... {$ticket_link|replace:'.php?tid=':'/'|replace:'&c=':'-'} but the problem is that when you try to add it to the email template via the admin area, it will change & to & ; (space added before semi-colon to avoid the f0rum software changing it back to an ampersand!) when you save changes... and so that part of the replace will not work. the easiest way to get it to work, would be to edit the email template directly in the database (via phpmyadmin or another tool) - doing that, you can enter the code exactly as you want to and it won't get changed by WHMCS... the templates are in tblemailtemplates and take a backup of the database just in case you run into issues. 0 Quote Link to comment Share on other sites More sharing options...
Neklawy Posted June 20, 2018 Author Share Posted June 20, 2018 Yes @brian! you are right, the problem with & ; I will try to edit that directly via phpMyAdmin if I can't write a hook However, I tried to wrote a hook and I found these is works only inside clientarea templates not email templates function hook_ticket_seo_url($vars) { global $CONFIG; $ticketid = $vars['tid']; $tickethash = $vars['c']; $newticketlink = $CONFIG['SystemURL'].'/ticket/'.$ticketid.'/'.$tickethash; return array("ticket_link" => $newticketlink); } add_hook("ClientAreaPage", 1, "hook_ticket_seo_url"); add_hook("EmailPreSend", 1, "hook_ticket_seo_url"); Any suggestion please? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted June 20, 2018 Share Posted June 20, 2018 46 minutes ago, Neklawy said: I will try to edit that directly via phpMyAdmin if I can't write a hook if you want my suggestion, just edit the email template in the database - writing a hook for this is overkill when you can easily edit the template... also, you assume that these support ticket variables are easily accessible in a presend hook - that may be a false assumption. 48 minutes ago, Neklawy said: However, I tried to wrote a hook and I found these is works only inside clientarea templates not email templates they're different beasts and just because a variable exists in a client area template, it doesn't necessarily mean that it will exist in an email template (and/or be called the same name), e.g., i'm not even sure the hash exists as a separate variable, so that may have to be pulled from the db... and in your example hook, $tid & $c would only be available on the viewticket page anyway, so a clientareapage hook would be the wrong hook to use even if this was for the client area. i'd file this under "not worth wasting time on" when there is an easier solution. 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.