Jump to content

ticket link replace URL in email template


Neklawy

Recommended Posts

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
Link to comment
Share on other sites

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 &amp ; (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.

Link to comment
Share on other sites

Yes @brian! you are right, the problem with &amp ;

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?

Link to comment
Share on other sites

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. :idea:

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