Tuesday, May 29, 2012

Joomla 2.5!: Classes for Accessing Database

For selecting:

$db = JFactory::getDBO();
$query = $db->getQuery(true);
$results = $db->loadObjectList();
if ($results){
    foreach($results as $result) 

For inserting:
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->set("field1='value1', fieldn='valuen'");
To get the last insert id, use:

For udating:
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->set("field1='value1', fieldn='valuen'");

For simple query:

$db = JFactory::getDbo();
$query = "<YOUR QUERY>";

Monday, May 28, 2012

IE CSS: Make input password same size with input text

Let declare css for input types with same font, e.g:

<style type="text/css">
  input {
      font-family: sans-serif;                

Tuesday, May 22, 2012

Encrypt by PHP & Decrypt by ASP.NET (C#) and vice versa

Ref: http://stackoverflow.com/questions/1278974/php-encryption-vb-net-decryption

php.ini, enable:

Here is my modified code:

PHP file:

function decryptRJ256($key,$iv,$string_to_decrypt)
    $string_to_decrypt = base64_decode($string_to_decrypt);
    $rtn = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, $string_to_decrypt, MCRYPT_MODE_CBC, $iv);
    $rtn = rtrim($rtn, "\0\4");

function encryptRJ256($key,$iv,$string_to_encrypt)
    $rtn = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $string_to_encrypt, MCRYPT_MODE_CBC, $iv);
    $rtn = base64_encode($rtn);

$ky = 'lkirwf897+22#bbtrm8814z5qq=498j5'; // 32 * 8 = 256 bit key
$iv = '741952hheeyy66#cs!9hjv887mxx7@8y'; // 32 * 8 = 256 bit iv

$text = "Here is my data to encrypt !!!";

$etext = encryptRJ256($ky, $iv, $text);
$dtext = decryptRJ256($ky, $iv, $etext);

header('Location: http://localhost/test.aspx?t='.$etext);


public static string DecryptRJ256(string prm_key, string prm_iv, string prm_text_to_decrypt) {

var sEncryptedString = prm_text_to_decrypt;

var myRijndael = new RijndaelManaged() {
 Padding = PaddingMode.Zeros,
 Mode = CipherMode.CBC,
 KeySize = 256,
 BlockSize = 256

var key = Encoding.ASCII.GetBytes(prm_key);
var IV = Encoding.ASCII.GetBytes(prm_iv);

var decryptor = myRijndael.CreateDecryptor(key, IV);

var sEncrypted = Convert.FromBase64String(sEncryptedString);

var fromEncrypt = new byte[sEncrypted.Length];

var msDecrypt = new MemoryStream(sEncrypted);
var csDecrypt = new CryptoStream(msDecrypt, decryptor, CryptoStreamMode.Read);

csDecrypt.Read(fromEncrypt, 0, fromEncrypt.Length);

return (Encoding.ASCII.GetString(fromEncrypt));

public static string EncryptRJ256(string prm_key, string prm_iv, string prm_text_to_encrypt) {

var sToEncrypt = prm_text_to_encrypt;

var myRijndael = new RijndaelManaged() {
 Padding = PaddingMode.Zeros,
 Mode = CipherMode.CBC,
 KeySize = 256,
 BlockSize = 256

var key = Encoding.ASCII.GetBytes(prm_key);
var IV = Encoding.ASCII.GetBytes(prm_iv);

var encryptor = myRijndael.CreateEncryptor(key, IV);

var msEncrypt = new MemoryStream();
var csEncrypt = new CryptoStream(msEncrypt, encryptor, CryptoStreamMode.Write);

var toEncrypt = Encoding.ASCII.GetBytes(sToEncrypt);

csEncrypt.Write(toEncrypt, 0, toEncrypt.Length);

var encrypted = msEncrypt.ToArray();

return (Convert.ToBase64String(encrypted));

protected void Page_Load(object sender, EventArgs e)
//Shared 256 bit Key and IV here
string sKy = " lkirwf897+22#bbtrm8814z5qq=498j5 "; //32 chr shared ascii string (32 * 8 = 256 bit)
string sIV = " 741952hheeyy66#cs!9hjv887mxx7@8y "; //32 chr shared ascii string (32 * 8 = 256 bit)

string t = Request.QueryString["t"].ToString();
t = t.Trim().Replace(" ", "+");
Button1.Text = DecryptRJ256(sKy, sIV, t);

Friday, May 18, 2012

Joomla! 2.5: Latest News Enhanced Modules

Recommend it for your website:

Thursday, May 17, 2012

Joomla: show module title

Joomla won't show module title if your template declares display style of the module is "none" or nothing.
Check your template to CHANGE it:
<jdoc:include type="modules" name="position-name" style="none" />
<jdoc:include type="modules" name="position-name" style="xhtml" />

Joomla: using {loadposition} and {loadmodule} in articles

There are two features in Joomla that allow you to easily place modules directly inside articles:
  • loadposition allows you to publish all the modules in a particular position.
  • loadmodule allows you to publish just one particular module.
One of our students was using these features to create a layout but wasn't happy with how it looked inside his article. He wanted more control.
This tutorial will show you how to place modules inside your article with more style. Here's what we're going to do:
  • We're going to take two standard modules: Login Form and Who's Online.
  • We'll combine them inside one article.
  • We'll rearrange them on the page using divs so that they are side-by-side.
  • We'll use inline styles to give the modules some color.
This should get you started with this technique and from there you can take it to limit of your styling ability. Be sure to check out our online HTML and CSS courses for more help.

Step 1. Make Sure the Plugin is Enabled

  • Go to Extensions > Plugin Manager
  • Use the filter to find Content - Load Modules.
  • Check that Status shows a green check. If it's a red circle, click it and it will turn green.

Step 2: Create an Article

  • Create an article.
  • Load the login module by typing {loadmodule mod_login}. You can use this syntax to load any module by name.
  • Load the Who's online module by position by typing {loadpostition whoonline}
There is no actual template postilion called whoonline. You can make up your own module position names and use them for this technique. We'll show you how it gets created as we go. For now, just create an article.
I'm supposing this scenario. It's a membership drive, we want you to be able to sign up. If there is somebody online right now, we want you to click their name and get in touch. If it was real, I'd use something more powerful like a contact form module or a list of contacts. For this demonstration we just need some modules we all have access to so we can practice.

Step 3. View the page

This is what the page looks like. You don't have the Who's Online module showing yet. Let's learn how to put that in there. We already wrote the shot line of code. Let's create the module for it.

Step 4. Publish the Who's Online module

  • Go to Extensions > Module Manager > New
  • Choose the Who's Online Module and configure it.
  • Give it a title.
  • Create a position name. This is where we'll use that one we called whoonline. You can use any name you want as long as it is unique.
  • Save your changes.
  • View the article. Our newly published module now shows inside the article. So far we have loaded a module by name and by position. We invented a position, but you can also use a template postilion if you want a published module from another page to show here.

Step 5: Create divs for placement and styling

  • Both our modules are inside the article but they don't look very good yet.. Let's put the two modules side by side.
  • Edit your article and turn your editor to code view. If you have any problems at this point, please consult this tutorial.
  • One of the best ways to put these side by side is to use div tags. Create a wrapper, and float two more divs inside of it. Put your loadpostion/loadmodule code inside the divs.
2.<div id="div2" style="float: right; width: 350px; background-color: #00ff00;">
3.{loadpostition whoonline}
  • This is what the article looks like in the editor view.
  • It looks better on the front of the site:
If you know how to style with CSS you can use inline styles or get classes from your style sheet and create any look you want. You can position them color them, add additional text and pictures and much, much more.

CSS3 Box Shadow & Background Opacity / Transparency


Used in casting shadows off block-level elements (like divs).
.shadow {
  -moz-box-shadow:    3px 3px 5px 6px #ccc;
  -webkit-box-shadow: 3px 3px 5px 6px #ccc;
  box-shadow:         3px 3px 5px 6px #ccc;
  1. The horizontal offset of the shadow, positive means the shadow will be on the right of the box, a negative offset will put the shadow on the left of the box.
  2. The vertical offset of the shadow, a negative one means the box-shadow will be above the box, a positive one means the shadow will be below the box.
  3. The blur radius (optional), if set to 0 the shadow will be sharp, the higher the number, the more blurred it will be.
  4. The spread radius (optional), positive values increase the size of the shadow, negative values decrease the size. Default is 0 (the shadow is same size as blur).
  5. Color


Inner Shadow

.shadow {
   -moz-box-shadow:    inset 0 0 10px #000000;
   -webkit-box-shadow: inset 0 0 10px #000000;
   box-shadow:         inset 0 0 10px #000000;


Internet Explorer Box Shadow

You need extra elements...
<div class="shadow1">
 <div class="content">
  Box-shadowed element
.shadow1 {
 margin: 40px;
 background-color: rgb(68,68,68); /* Needed for IEs */

 -moz-box-shadow: 5px 5px 5px rgba(68,68,68,0.6);
 -webkit-box-shadow: 5px 5px 5px rgba(68,68,68,0.6);
 box-shadow: 5px 5px 5px rgba(68,68,68,0.6);

 filter: progid:DXImageTransform.Microsoft.Blur(PixelRadius=3,MakeShadow=true,ShadowOpacity=0.30);
 -ms-filter: "progid:DXImageTransform.Microsoft.Blur(PixelRadius=3,MakeShadow=true,ShadowOpacity=0.30)";
 zoom: 1;
.shadow1 .content {
 position: relative; /* This protects the inner element from being blurred */
 padding: 100px;
 background-color: #DDD;

One-Side Only

Using a negative spread radius, you can get squeeze in a box shadow and only push it off one edge of a box.
.one-edge-shadow {
 -webkit-box-shadow: 0 8px 6px -6px black;
    -moz-box-shadow: 0 8px 6px -6px black;
         box-shadow: 0 8px 6px -6px black;

Joomla! 2.5 alias for external url menu

By default, Joomla! 2.5 doesn't have alias for external url menu (hope it will be fixed next time). So it will insert datetime to the url for sub menus of this menu type.
Howerver, you can create an alias for this menu type as the following work around:
1. Change to another type of menu ==> fill alias name ==> save
2. Change back to external url type ==> save
Ola, done.

CSS3 rounded corners with border-radius

The CSS3 border-radius property allows web developers to easily utilise rounder corners in their design elements, without the need for corner images or the use of multiple div tags, and is perhaps one of the most talked about aspects of CSS3.
Since first being announced in 2005 the boder-radius property has come to enjoy widespread browser support (although with some discrepancies) and, with relative ease of use, web developers have been quick to make the most of this emerging technology.
Here’s a basic example:
This box should have a rounded corners for Firefox, Safari/Chrome, Opera and IE9.
The code for this example is, in theory, quite simple:
#example1 {
border-radius: 15px;
However, for the moment, you’ll also need to use the -moz- prefix to support Firefox (see the browser support section of this article for further details):
#example1 {
-moz-border-radius: 15px;
border-radius: 15px;

How it Works

Rounder corners can be created independently using the four individual border-*-radius properties (border-bottom-left-radius, border-top-left-radius, etc.) or for all four corners simultaneously using the border-radius shorthand property.
We will firstly deal with the syntax for the individual border-*-radius properties before looking at how the border-radius shorthand property works.

border-bottom-left-radius, border-bottom-right-radius, border-top-left-radius, border-top-right-radius

The border-*-radius properties can each accept either one or two values, expressed as a length or a percentage (percentages refer to the corresponding dimensions of the border box).

The Syntax:
border-*-*-radius: [ <length> | <%> ] [ <length> | <%> ]?

border-top-left-radius: 10px 5px;
border-bottom-right-radius: 10% 5%;
border-top-right-radius: 10px;
Where two values are supplied these are used to define, in order, the horizontal and vertical radii of a quarter ellipse, which in turn determines the curvature of the corner of the outer border edge.
Where only one value is supplied, this is used to define both the horizontal and vertical radii equally.
The following diagram gives a few examples of how corners might appear given differing radii:
If either value is zero, the corner will be square, not round.


The border-radius shorthand property can be used to define all four corners simultaneously. The property accepts either one or two sets of values, each consisting of one to four lengths or percentages.

The Syntax:
[ <length> | <percentage> ]{1,4} [ / [ <length> | <percentage> ]{1,4} ]?

border-radius: 5px 10px 5px 10px / 10px 5px 10px 5px;
border-radius: 5px;
border-radius: 5px 10px / 10px;
The first set of (1-4) values define the horizontal radii for all four corners. An optional second set of values, preceded by a ‘/’, define the vertical radii for all four corners. If only one set of values are supplied, these are used to determine both the vertical and horizontal equally.
For each set of values the following applies:
If all four values are supplied, these represent the top-left, top-right, bottom-right and bottom-left radii respectively. If bottom-left is omitted it is the same as top-right, if bottom-right is omitted it is the same as top-left, and if only one value is supplied it is used to set all four radii equally.

Browser Support

At present Opera (version 10.5 onward), Safari (version 5 onward) and Chrome (version 5 onward) all support the individual border-*-radius properties and the border-radius shorthand property as natively defined in the current W3C Specification (although there are still outstanding bugs on issues such as border style transitions, using percentages for lengths, etc.).
Mozilla Firefox (version 1.0 onward) supports border-radius with the -moz- prefix, although there are some discrepancies between the Mozilla implementation and the current W3C specification (see below).
Update:Recent Firefox nightly versions support border-radius without the -moz- prefix.
Safari and Chrome (and other webkit based browsers) have supported border-radius with the -webkit- prefix since version 3 (no longer needed from version 5 onward), although again with some discrepancies from the current specification (see this article for further details of how older versions of Webkit handle border-radius).
Even Microsoft have promised, and demonstrated in their recent preview release, support for border-radius from Internet Explorer 9 onward (without prefix).

The -moz- prefix

Mozilla’s Firefox browser has supported the border-radius property, with the -moz- prefix, since version 1.0. However, it is only since version 3.5 that the browser has allowed elliptical corners, i.e. accepting two values per corner to determine the horizontal and verical radii independently. Prior to version 3.5, the browser only accepted one value per corner, resulting in corners with equal horizontal and vertical radii.
The syntax, from Firefox 3.5 onwards, for the main part follows the current W3C specification, as described throughout this article, prefixed by -moz-. The only major difference is in the naming of the individual border-*-radius properties, with the -moz- prefixed properties following a slightly different naming convention as follows:

W3C Specification Mozilla Implementation
border-radius -moz-border-radius
border-top-left-radius -moz-border-radius-topleft
border-top-right-radius -moz-border-radius-topright
border-bottom-right-radius -moz-border-radius-bottomright
border-bottom-left-radius -moz-border-radius-bottomleft

The Mozilla implementation also behaves slightly differently from the specification when percentages are supplied. You can read more on the Mozilla Developer Center here.

Cross Browser Examples

Here’s a few basic examples that should work in current versions of Firefox, Safari/Chrome, Opera and even IE9:

#Example_A {
height: 65px;
-moz-border-radius-bottomright: 50px;
border-bottom-right-radius: 50px;
#Example_B {
height: 65px;
-moz-border-radius-bottomright: 50px 25px;
border-bottom-right-radius: 50px 25px;
#Example_C {
height: 65px;
-moz-border-radius-bottomright: 25px 50px;
border-bottom-right-radius: 25px 50px;
#Example_D {
height: 5em;
width: 12em;
-moz-border-radius: 1em 4em 1em 4em;
border-radius: 1em 4em 1em 4em;
#Example_E {
height: 65px;
-moz-border-radius: 25px 10px / 10px 25px;
border-radius: 25px 10px / 10px 25px;
#Example_F {
height: 70px;
width: 70px;
-moz-border-radius: 35px;
border-radius: 35px;

Additional Notes & Further Reading

The W3C Backgrounds and Borders Specification goes into further detail on how the corner is shaped (especially in circumstances where two adjoining border have different widths), the effect of border-radius on background images, color and style transitions, what happens when curves overlap and the effect of border-radius on tables.
This is best explained in the following sections of the specification:

Tuesday, May 15, 2012

Joomla! 2.5 Menu Manager: Link CSS Style

To assign a custom CSS class to a Joomla menu link
  1. From the Joomla Admin menu, select Menus > Main Menu (or whatever menu you want to edit).
  2. Click the menu link to which you want to assign a custom CSS class.
  3. From the menu options on the right side of the page, click Link Type Options.

    Joomla Menu Item Custom Class Configuration
  4. In the Link CSS Style field, enter a CSS class name

    IMPORTANT: Use only alpha numerical characters, hyphens, and underscores, but no spaces.
  5. Click Save & Close to save your changes.

    Joomla adds the custom class to the menu link.

    Custom CSS Class in Joomla Menu Link
  6. Now you can use a CSS class to create custom formatting for the link you modified. For example, create a CSS class in your css stylesheet; make sure to use the exact same class name you used in the link:
    a.homestyle {color:#fff;font-size:11px;background:#666}

Joomla! 2.5 free drop down menu

DJ-Menu is a good drop down menu.

Download: http://extensions.joomla.org/extensions/structure-a-navigation/menu-systems/drop-a-tab-menus/16232

Parameters instruction: http://dj-extensions.com/dj-menu/blog

DJ-Menu is a suckerfish menu with animated mootools effects.
Now, you can easily manage whether the menu is animated or just scriptless css drop-down.
Navigate Extensions > Module Manager and choose DJ-Menu module.
Let's take a look at Module Parameters:


Short description:
  • Menu name – choose the name of menu (default is mainmenu) Navigate to Menus > Menu Manager


  • Include default css – if you want to change menu CSS styling, change this parameter to 'No' and copy djmenu.css and djmenu_fx.css files from /modules/mod_djmenu/assets/css/ into /templates/[your_template]/css/. Then you may change font sizes, colors, backgrounds, etc. of DJ-Menu elements. The only difference between djmenu.css and djmenu_fx.css is replacement of all occurences of 'li:hover' (djmenu.css) with 'li.hover' (djmenu_fx.css)
    If you upgrade your DJ-Menu from version less than 1.5.0 you also need to replace all occurences of '#dj-main' with '.dj-main'.
  • Enable Effects - if Yes, submenus will be showing and hiding with nice mootools effects. Requirements: Joomla! 1.5.19+ , enabled 'System - Mootools Upgrade' plugin (available since Joomla! 1.5.19 as core plugin)
  • Wrapper id - submenu will change direction if it goes out the container with wrapper id. Default wrapper is container with .dj-main class
  • Vertical transition at first level - enable vertical transition of submenu at first level. You can mix vertical, horizontal and fade transition as you want.
  • Horizontal transition at first level - enable horizontal transition of submenu at first level. You can mix vertical, horizontal and fade transition as you want
  • Fade effect at first level - enable fade transition of submenu at first level. You can mix vertical, horizontal and fade transition as you want
  • Vertical transition at other levels - enable vertical transition of submenu at second and further levels. You can mix vertical, horizontal and fade transition as you want.
  • Horizontal transition at other levels - enable horizontal transition of submenu at second and further levels. You can mix vertical, horizontal and fade transition as you want
  • Fade effect at other levels - enable fade transition of submenu at second and further levels. You can mix vertical, horizontal and fade transition as you want
  • Tansition effect – choose the transition effect type
  • Effect duation - set effect duration time in miliseconds (1000 ms = 1 second)
  • Delay time before close submenu - set delay time in miliseconds (1000 ms = 1 second)

Remember to publish System – Mootools Upgrade plugin to get mootools effects work properly.
Navigate to Extensions > Plugin Manager and check if the plugin is published.
Joomla! 1.5.19+ (plugin is available since Joomla! 1.5.19 as core plugin)

Saturday, May 12, 2012

Joomla! 2.5: Create an Offline Group

1. Login to back-end with superuser right.
2. Click on "Users > Groups > Add New Group".
Enter a title such as "Offline Group" and choose "Registered" option for the "Group Parent" drop-down list and then click on "Save & Close" right-top button. Now that we have created a group we need to create an access level for this group.
3. Click on "Users > Access Levels > Add New Access Level", enter a title for this new access level like "Offline Access", put the check mark next to "Offline Group" then "Save & Close";
4. Click on "Site > Global Configuration" and select the "Permissions" tab. We see a list with all the groups across their permission settings (Calculated Settings). Then click on the "Offline Group" group, under calculated settings we see "Not Allowed" permission. To enable offline access for this group we need to select new setting on "Select New Setting" column for the "Offline Access" action.

We only have to change the value from "Inherited" to "Allowed".

For more info:

Thursday, May 10, 2012

Joomla 2.5 Authentication Plugins

The authentication plugins operate when users login to your site or administrator. The Joomla! authentication is in operation by default but you can enable Gmail or LDAP or install a plugin for a different system. An example is included that may be used to create a new authentication plugin.
Default on:
Default off:
  • Gmail Help (remember to enable curl & ssl libraries)
  • LDAP Help

CRM for Hotel: Why we need a good loyalty program

I stayed at a Marriott recently, and it took me half of a morning to find my Rewards number, so they could assign my points. Sure, it’s my fault I didn’t carry around my loyalty number around with me- but we all know there are so many programs it’s near impossible to do that. It’s almost expected now that nobody will have their member card with them. Barnes & Noble looks it up by last name and phone number. My video store, the same.
I stop by the front desk on the way to breakfast. I don’t have my number, so they lookup my Marriott rewards account by my last name and the billing zip code from the first time I had registered with them. I’ve only had two spanning the last 10 years, but no, neither work.
I remembered I had an email from them on my iPhone. I scrolled to it in front of the registration person and no, nowhere on it was my number. My points, my first name, but not my member number. (see below)
I tell the registration person not to worry and later that day when I remembered, I logged into the site. Still not so easy- you have to click around to your account, profile details (it’s not on there), and then finally the account profile (what’s the difference?) and there is the number, hidden amidst other details. The reason my zip code didn’t work is that it requires the four digit extension. I wonder if they require the dash?
Later that night return to the hotel and provide the number, and then they assigned points. I doubt my parents, or colleagues, would be as determined as me to get these free points. So the kind of rewards member they’re targeting is the cheap, coupon-clipping, business traveler. I doubt that’s their desirable target demographic.
On the site, if you forget your password- and if you forgot your number, you probably forgot your password, is accessible by filling out this strangely lengthy form:
I finally found it because I punched through my usual passwords and struck gold. The lessons I take from this: if someone is already a guest, and they want to assign points to their loyalty program, they should be searchable some of the common criteria .
- email address and/or
- first and last name
Also, the email should either have the account number in the email, or at least, one click away. Currently it’s 3 clicks, login, account page, then profile.
I wonder if they are trying to get regional data from their customers, because hospitality really leans on regional information. The problem is that they are creating this barrier to participation in the program. Perhaps that’s intentional too. If so, this is one of the most intricate, and relatively useless, process in CRM. We build this system, but don’t really want you to participate. We make it hard, so you won’t really take advantage of our offers.
I know it should be different online where there are more fraudulent schemes, but doubting or questioning someone who is already paying X dollars a night in the hotel seems contrary to the hospitality industry’s general attitude towards the customer.
I wonder at these loyalty programs- you get a great segment of your customer database, but is it worth setting up an entirely different experience, and managing the data, which can go awry like in the example above? WellsFargo has a very easy Rewards system that happens very passively from the consumer point of view, no unique number, just a link you click on to agree to the terms, and then you start accruing points.

Saturday, May 5, 2012

Joomla! 2.5 User Profile Fields

Joomla! 2.5 has a new system plugin named "User - Profile" which can help to expand fields of user profile.
-Enable it: Backend >> Extensions >> Plug-in Manager >> enable User Profile
-Add more fields: edit 2 files plugins/user/profile/profile.xml and plugins/user/profile/profiles/profile.xml

Thursday, May 3, 2012

Gmail Contextual Gadgets

Getting started with Gmail Contextual Gadgets, see at:

The Gmail gadget does not work?
Ad the &nogadgetcache=1 parameter in your Gmail URL as follows:
Subscribe to RSS Feed Follow me on Twitter!