Archive for February, 2013

Zonne grote sneeuwbal jonguh! http://t.co/4qHedJHEmj

BD-E2cwCQAEKOY-

Post to Twitter

Comments No Comments »

Since a few months I’ve been using WHMCS for all invoicing for my company Exa-Omicron. I’ve altered the standard email templates, but there was one thing that would not work very nicely and the richtext editor is causing problems.

I wanted to use foreach loops in the email templates to loop over all the invoice items. This way the customer can see all the invoice line items in the email instead of opening the PDF. By using a table for the invoice items, I made the email look almost exactly the same as the invoice PDF. So for example:

<p><strong>Invoice Items</strong></p>

<table style=”border-collapse: collapse;”>
<tbody><tr style=”background-color: #000; color: #fff”><td style=”border: 1px solid black;”>Description</td><td align=”right” style=”border: 1px solid black;”>Total</td></tr>

{foreach from=$invoice_items item=invline}

<tr><td style=”border: 1px solid black;”>{$invline.description}</td><td align=”right” style=”border: 1px solid black;”>{$invline.amount}</td></tr>

{/foreach}

<tr><td align=”right”>Subtotal</td><td align=”right”><strong>{$invoice_subtotal}<strong></strong></strong></td></tr>
<tr><td align=”right”>{$invoice_tax_rate} VAT</td><td align=”right”>{$invoice_tax}</td></tr>
<tr><td align=”right”><strong>Total</strong></td><td align=”right” style=”border-top: 1px solid black;”><strong>{$invoice_total}</strong></td></tr>
</tbody></table>

But when reopening the email template, the richtext editor does not understand the Smarty template elements like foreach. The richtext editor tries to correct the HTML and moves the foreach lines outside of the <table> tags. but this makes the whole email template unusable, because it will not generate correct HTML anymore. My html knowledge is good enough to write templates without a richtext editor, so I searched for an option to disable the richtext editor completely. Unfortunately I could not find such an option in WHMCS. So I added a apache rewriteengine rule in the .htaccess file to forward the webrequest from the browser to always disable the richtext editor.

# Always disable richtext editor
RewriteCond %{REQUEST_URI} ^/admin/configemailtemplates.php$
RewriteCond %{QUERY_STRING} ^action=edit&id=([0-9]+)$
RewriteRule .* ./admin/configemailtemplates.php?action=edit&id=%1&noeditor=1 [L]

So when the browser requests the url /admin/configemailtemplates.php and the query string only holds a action = edit and a numeric id, then the browser is redirected to the exactl same URI, but with a &noeditor=1 added to the query string.

And this solved all my ‘richtext editor tries to correct html’ issues 🙂

Post to Twitter

Comments No Comments »

Finally somebody shows what really happens in the dark! youtube.com/watch?v=wTaXI9…

Post to Twitter

Comments No Comments »

o/ v4.2.2 😉 /cc: @mvdvlies

Post to Twitter

Comments No Comments »

When you need to configure multiple servers it’s always good to look at some configuration management software like Puppet of Chef. But there is a new kid in town and it looks promissing. I’ve played around with Ansible a bit to setup a complex network configration on 5 blade servers running a CentOS minimal. I mentioned this last weekend to Fabian Arrotin last weekend at FOSDEM and he told me to put that info online. So here it is!

Read the rest of this entry »

Post to Twitter

Comments 11 Comments »

We zijn er! #fosdem @mvdvlies @mhzijlstra @adebree http://t.co/dEigJYRC

BCF4K5-CIAEcfP3

Post to Twitter

Comments 3 Comments »

Uitzicht in hotel in Brussel. Morgen #fosdem http://t.co/YChccz8V

BCCJF37CAAECgge

Post to Twitter

Comments 1 Comment »