Jump to content
Sign in to follow this  
websavers

Template Syntax Errors when else is used

Recommended Posts

I've been having an odd issue with multiple email templates. It seems like using an {else} results in the following errors in the activity log:

Smarty Error: Syntax error in template "mailMessage:mailMessage:plaintext" on line 33 "{$signature}" unclosed {if} tag

I'm getting this with at least two different email templates. Here's one such template in plaintext for "Invoice Created" the one that the above error is specifically referring to:

<p>Hey {$client_name},</p>
{if $ticket_department eq "Sales"}Since you normally pay with PayPal, you should already have a subscription which will automatically renew on {$invoice_date_due}. If your subscription was previously canceled, then you should use the link below to complete payment manually.{else}According to our records, you normally complete payment with {$invoice_payment_method}, however {$invoice_payment_method} does not support automatic renewal! This means you will need to click the link below to complete payment manually for every invoice we create for you. If you'd like your invoices to automatically renew, without your intervention, we suggest switching your default payment method to a Credit Card or a PayPal Subscription. Just <a href="[snipped]/clientarea.php?action=details">click here to change your default payment method</a>for all invoices within your account. If you'd prefer to continue paying with {$invoice_payment_method}, simply click the link below to proceed.{/if}
<p><strong>Invoice Details</strong></p>
<p>Invoice #{$invoice_num}<br />Default Payment Method: {$invoice_payment_method}<br />Amount Due: {$invoice_total}<br />Date Created: {$invoice_date_created}<br />Due Date: {$invoice_date_due}</p>
<p><strong>Invoice Items</strong></p>
<p>{$invoice_html_contents} <br /> ------------------------------------------------------</p>
<p>You can login to your client area to view and pay the invoice here: {$invoice_link}</p>
<p>{$signature}</p>

Yet the messages seem to send and display just fine. Is it possible the syntax parser is reading the word "if" in the body and thinking it's another {if} statement?

Edited by jas8522

Share this post


Link to post
Share on other sites

Near as I can tell, single quotes should be used around things in this; so not "Sales". but 'Sales'. Also be careful about using any quotes within the statement, since that may be seen as special characters and end a statement early. You have several in there, like "you'd" and the URL to pay having double quotes. That's what I'd look at first. 

Edited by bear

Share this post


Link to post
Share on other sites
2 minutes ago, bear said:

Near as I can tell, single quotes should be used around things in this; so not "Sales". but 'Sales'. 

Ah! Thanks for the tip: I'll give that a try :)

Sadly their sample code uses double quotes: {if $ticket_department eq "Sales"}

If single quotes solves this, I'll submit that sample code as a bug :P

Edited by jas8522
Add sample code

Share this post


Link to post
Share on other sites
1 hour ago, jas8522 said:

Yet the messages seem to send and display just fine. Is it possible the syntax parser is reading the word "if" in the body and thinking it's another {if} statement?

unlikely - if I use your code in a v7.4.1 dev email template, then I see what you see even if I remove the IFs from the text - the email sends, but there is an error in the activity log.

if I type the following directly into the tblemailtemplates database table...

<p>Hey {$client_name},</p>
{if $ticket_department eq "Sales"}
Since you normally pay with PayPal, you should already have a subscription which will automatically renew on {$invoice_date_due}. If your subscription was previously canceled, then you should use the link below to complete payment manually.
{else}
According to our records, you normally complete payment with {$invoice_payment_method}, however {$invoice_payment_method} does not support automatic renewal! This means you will need to click the link below to complete payment manually for every invoice we create for you. If you'd like your invoices to automatically renew, without your intervention, we suggest switching your default payment method to a Credit Card or a PayPal Subscription. Just click <a href="http://www.whmcs.com/clientarea.php?action=details">here</a> to change your default payment method for all invoices within your account. If you'd prefer to continue paying with {$invoice_payment_method}, simply click the link below to proceed.
{/if}
<p><strong>Invoice Details</strong></p>
<p>Invoice #{$invoice_num}<br />Default Payment Method: {$invoice_payment_method}<br />Amount Due: {$invoice_total}<br />Date Created: {$invoice_date_created}<br />Due Date: {$invoice_date_due}</p>
<p><strong>Invoice Items</strong></p>
<p>{$invoice_html_contents} <br /> ------------------------------------------------------</p>
<p>You can login to your client area to view and pay the invoice here: {$invoice_link}</p>
<p>{$signature}</p>

then it will send without generating any errors in the activity log.... but edit the template and the error returns.

there's something about that link that it doesn't like - remove it and the error goes away... also, for some reason, it removes the space after the closing </a>.

you could report it as a bug to WHMCS... or since you know it's working (e.g sending the email), you could ignore it.

I should also add that $ticket_department won't be available to the Invoice Created template... unless you've written a hook to add it.

Share this post


Link to post
Share on other sites

@brian!Good point regarding the $ticket_department variable... can't even remember how that got in there. Must have been a copy/paste error from way back when. I'll definitely get that fixed up. It was supposed to be: {if $invoice_payment_method eq 'PayPal'}

My other template exhibiting the same issue does *not* have conditionals with quotes in them, but it *does* have a link with double quotes. I wonder if perhaps switching all my URLs to single quotes will help. Worth a try! I'll update here with the results.

Edited by jas8522

Share this post


Link to post
Share on other sites

Fixed up the $invoice_payment_method variable and tried swapping quotes for single quotes. All of my quotes applied to URLs were changed back to double quotes upon save. But I was able to change all my conditional comparison strings to single quotes and have them stay that way. Sadly it didn't make a difference.

As @brian! hinted at, once I removed all links from within my conditional text, the syntax error stopped showing up in the logs. I'm going to submit this as a bug.

Share this post


Link to post
Share on other sites

Support set me straight. My variable checking model was the problem. We should not be using {if $variable} to check if it exists or is not empty. As suggested by WHMCS staff, we should instead be using {if isset($variable)} or this worked fine for me as well: {if !empty($variable)} 

Once I switched up the conditionals to check variables in that manner, all syntax errors stopped.

Share this post


Link to post
Share on other sites
3 hours ago, jas8522 said:

We should not be using {if $variable} to check if it exists or is not empty.

but in your sample code you weren't doing that. :?:

granted you were using a variable that wouldn't exist, but your code above checks if a variable equals something.... that's perfectly legitimate in the email templates and Smarty in general.

Share this post


Link to post
Share on other sites
13 hours ago, brian! said:

but in your sample code you weren't doing that. :?:

granted you were using a variable that wouldn't exist, but your code above checks if a variable equals something.... that's perfectly legitimate in the email templates and Smarty in general.

Huh, indeed. The other template I was working with did have those kinds of conditional checks. But that doesn't explain why this one didn't work. I've got URLs within the conditionals of my final (working) template as well and no issues now. Color me stumped.

Share this post


Link to post
Share on other sites

Also just noticed this in my Activity Log as an error.

The unmodified default WHMCS email templates are giving errors such as:

Quote

Smarty Error: Syntax error in template "mailMessage:mailMessage:plaintext" on line 17 "{$signature}" unclosed {else} tag

As far as I can see, this error is caused/reported when a hyperlink is included within the body of an if/else statement. i.e. removing the hyperlink removes the error.........

Come on WHMCS...test your own default templates!

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

  • Similar Content

    • By ModulesGarden
      As an owner of a web hosting business, you probably know well how many factors and variables must be considered in the process of a successful transaction.

      But what if we told you that all the efforts you put into your business, like catchy advertising, personalized recommendations and accurate descriptions, still fail to bring around 70% of the transactions to an end? That is how often clients leave items in their carts without completing the checkout. Quite striking, isn’t it?

      We are here with a simple yet powerful solution to that problem. Having in mind certain habits typical for e-commerce customers, we have come up with a module which does most of the job for you.

      Thanks to Abandoned Cart For WHMCS, you will be able to easily send out customizable email reminders to potential buyers - both your guests and logged in clients - at various time intervals, and no less importantly, view statistics and log entries concerning added or removed products.

      We obviously want to share this wonderful joy of the new release with you, so if you are willing to put our product to the test, do it now and grab a spectacular 33% discount!

      Still curious? Find a full write-up about Abandoned Cart For WHMCS on our Blog!




      Need Custom Software Development For Your Business?
      Get Your Free Quote Now! Specially for you we will adapt an application and its design to your own needs, create a new module or even a completely new system built from scratch!
    • By SwiftModders
      SwiftModders specializes in premium, responsive WHMCS Themes designed to make your business stand out from your competition! Please look at what our customers say about us on WHMCS Marketplace and Trustpilot.
      All WHMCS Themes provided by SwiftModders are powered by our custom-built Theme Installer module that allows you to:
      Customize the settings for your theme installations Update your theme automatically Provide debugging tools, health checks, and license management Menu management system to customize your WHMCS navigation on-the-fly Developer-friendly CSS/SCSS editor support for advanced customizations ---
      Allure WHMCS Client Theme - Starts at $70 per year*
      Learn More | Purchase
      SwiftModders WHMCS Client Theme - Starts at $45 per year*
      Learn More | Purchase
      SwiftModders WHMCS Admin Theme - Starts at $35 per year*
      Learn More | Purchase
      *All prices above DO NOT reflect the 30% discount. One-time licenses are also available for all themes!
      ---
      Need something a little more custom?
      SwiftModders offers completely custom WHMCS theme development for businesses that want a better user experience and consistency with their brand. If that sounds like you, let's chat!
    • By ModulesGarden
      1. It’s Christmas time - 10% OFF storewide!

      The bells can already be heard jingling, so allow us to express the kindest wishes to you all, dearest clients! May your Christmas be a wonderful time of delight, happiness and peacefulness, spent with family and friends. Cheers from the whole ModulesGarden team!

      We’re excited to let you know that one more gift is waiting for you, as our Christmas Promotion has just begun – each WHMCS module you can find on our marketplace has been touched by a 10% discount! Before you start browsing, take a quick stop at our Blog and get the jolly promo code, which can be used until January 8th, 2023.

      Make the atmosphere even more magical!




      2. CRM For WHMCS 2.9.0

      Completely absorbed by the recent workflow, our developers have crafted a huge update to our well-known module, famous for the automated management of customer relationships. Precisely, we’re calling out CRM For WHMCS!

      By means of the 2.9.0 release, your business connections will get substantially improved by means of as many as 10 spanking new features! We’ll put just a few under the microscope right away:
      Set “Pending”, “Confirmed”, “Closed” or any other custom status with defined color to follow-ups, Modify the email subject and the content when the email template, that is about to be sent, is loaded, Tag staff members using the “@” sign in the notes in order to notify them if they have been mentioned. Crowning the unbelievable advancement, that is CRM For WHMCS 2.9.0, is the flawless compatibility with the latest WHMCS V8.6 and PHP 8.1. Discover its whole extent on our website along with a little surprise!

      Read more about CRM For WHMCS 2.9.0!




      3. OpenStack Projects For WHMCS 1.5.0

      On the other hand, you may want to start the search for a perfect gift with a detailed look at our popular module, crafted to allow the provisioning of OpenStack projects in a completely automated manner. Configuring resource bundles and assigning user roles remotely? This description fits only one piece of software – OpenStack Projects For WHMCS.

      The just released 1.5.0 version is a perfect idea for a Christmas gift this year, with its support for OpenStack "Zed" and the immaculate compatibility with WHMCS V8.6 and PHP 8.1. The changelog doesn’t however end there, so discover it in its entirety and make this Christmas even more memorable!

      Read more about OpenStack Projects For WHMCS 1.5.0!




      4. Office 365 For WHMCS 3.1.0

      You are not mistaken, this is the third major update that our developers have conjured just recently! Provisioning Microsoft Office 365 plans in your WHMCS has now become even more advanced, all thanks to the upgraded Office 365 For WHMCS.

      Owing to the impeccable support for WHMCS V8.6 and PHP 8.1 in combination with a set of extensive improvements, the 3.1.0 version is ready to amaze you even more than it already could.

      Read more about Office 365 For WHMCS 3.1.0!




      5. GoGetSSL For WHMCS 2.8.1 & Latest Updates

      These past days have been all about upgrades, resulting in another refinement to our free toolkit designed for the provisioning of SSL certificates. Take a closer look at GoGetSSL For WHMCS 2.8.1 and find out about the news we have introduced this week!

      The ongoing task to equip all our modules with impeccable support for the latest WHMCS V8.6 has resulted in another set of updates, laid out below for your comfort:
      Domain & Email Forwarding For WHMCS - v1.4.4 IP Manager For WHMCS - v2.5.14 Product Free Trial Manager For WHMCS - v1.0.1 R1Soft Backups For WHMCS - v1.1.12 Unban Center For WHMCS - v2.3.8 Zimbra Email For WHMCS - 2.1.10


      Need Custom Software Development For Your Business?
      Get Your Free Quote Now! Specially for you we will adapt an application and its design to your own needs, create a new module or even a completely new system built from scratch!
    • By ModulesGarden
      1. OpenStack VPS & Cloud For WHMCS 2.2.0

      It’s no secret that Christmas is getting closer with each day that passes, but have you already included yourself in the gift shopping spree? If you’re unsure what your heart desires, let us solve the mystery by announcing this week’s news – an update to OpenStack VPS & Cloud For WHMCS!

      The 2.2.0 version of this popular module for the provisioning of OpenStack virtual servers has a few exciting tricks up its sleeve, so let’s take a closer look at some of them:
      OpenStack "Zed" support, Setting the "Availability Zone" as the configurable option, Running scheduled tasks manually from the admin area, without waiting for the cron job. Worth highlighting is also the introduced WHMCS V8.6 and PHP 8.1 support - why don't you take a look at the whole changelog and stick around to grab a special 10% discount?

      Read more about OpenStack VPS & Cloud For WHMCS 2.2.0!




      2. Under the microscope: Email Notifications Organizer For WHMCS!

      Even though we have crafted an abundance of practical modules so far, we’re constantly thinking of new solutions that would make daily life easier for you and your clients. This was exactly the case with our latest creation – Email Notifications Organizer For WHMCS!

      So as to display its features in as much detail as possible, we have uploaded a fresh entry on our Blog, which will also show you the benefits that you and your customers will experience thanks to this module. Reduced carbon footprint and well-organized inbox are just two examples!

      Read more about Email Notifications Organizer For WHMCS!




      3. New EasyDCIM business guide: How to make clients feel cared for

      You surely know that in order for a web hosting business to thrive, a lot of different aspects need to be focused on, however particularly one of them should by all means become the priority: the customer.

      Putting your clientele in the center of attention by building a customer-centric business model is a subject close to the heart of EasyDCIM team, who have decided to share their knowledge in a recent Blog post, displaying 10 ways how to best appeal to clients!

      So, if you were looking for ways to ensure the success of your web hosting enterprise, perhaps this is the direction you as a provider should take. There is only one way to find out – start reading!

      Continue on the EasyDCIM Blog!




      Need Custom Software Development For Your Business?
      Get Your Free Quote Now! Specially for you we will adapt an application and its design to your own needs, create a new module or even a completely new system built from scratch!
    • By ModulesGarden
      1. Email Notifications Organizer For WHMCS - 25% OFF!

      Our team never misses the opportunity to enhance an already existing product, but creating a fresh piece of software entirely from scratch is especially rewarding. Let’s welcome another member of our marketplace – Email Notifications Organizer For WHMCS!

      Now you can introduce a whole new level of convenience to your clientele, by sending them data from multiple email notifications about unpaid invoices or expiring domains in the form of single messages. You will be able to set a custom template and delivery time for such notifications and see summaries of blocked and delivered emails for a chosen time period. Quite extraordinary, isn’t it? You'll optimize the usage of your server resources and immediately notice extra space, not to mention the reduced carbon footprint of your entire enterprise.

      It’s also been equipped with support for the latest WHMCS V8.6 and PHP 8.1, so go ahead and add a unique boost to your business now at a phenomenal 25% discount!

      Read more about Email Notifications Organizer For WHMCS!




      2. Another Set of WHMCS V8.6 Compatibility Updates

      WHMCS V8.6 has just been promoted to General Availability, meaning it’s now the recommended version for all installations and updates. Right after having heard the news, we’ve focused completely on equipping our products with impeccable support! Report Generator For WHMCS 4.3.0 with ACL is certainly a highlight, but let’s check what other products have also joined the official compatibility list of late:
      Client Area Popup For WHMCS – v1.3.5 DirectAdmin Extended For WHMCS – v3.9.1 Google Cloud Virtual Machines For WHMCS – v1.3.1 Hetzner VPS For WHMCS – v1.7.1 Product Feedback Center For WHMCS – v2.1.1


      3. GoGetSSL For WHMCS 2.7.9

      We’re closing in on this week’s set of news by sharing one more update, this time to our completely free toolkit designed to supply your clients with SSL certificates – GoGetSSL For WHMCS 2.7.9. View the changelog and see what’s new!

      Read more about GoGetSSL For WHMCS 2.7.9!




      Need Custom Software Development For Your Business?
      Get Your Free Quote Now! Specially for you we will adapt an application and its design to your own needs, create a new module or even a completely new system built from scratch!
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • 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