Friday, 4 October 2013

Joomla contact form validation not working

Joomla has an in built contact form validation. But Joomla does not provide an error message or popups for the invalid entry. so sometimes we don't notice the warnings because of a mismatch in the css. In order to solve try adding the following line in the template.css.

.invalid {color:red;}


 Now the labels will be shown as red color if invalid data is entered, and also it will not allow form to submit.

Knowing if need for smartcard on certificate

To know if the private key lives in hardware (usually smartcard) without Windows popping up a message such as "please insert smartcard".

RSACryptoServiceProvider rsa = myX509Instance.PrivateKey as RSACryptoServiceProvider; // problem here
if(rsa.CspKeyContainerInfo.HardwareDevice)
{
     // needs for some hardware..
}

Read credentials from a smart card c# programming

If you are programming in windows, then once you insert the smart card into a reader, windows will fetch all the certificates to the certificate store. Then we can retrieve all the credentials in the certificate and thereby the smart card using the following code:

var smartCardCerts = new List<X509Certificate2>();
var myStore = new X509Store(StoreName.My, StoreLocation.CurrentUser);
foreach(X509Certificate2 cert in myStore)
{
  if( !cert.HasPrivateKey ) continue; // not smartcard for sure
  var rsa = cert.PrivateKey as RSACryptoServiceProvider;
  if( rsa==null ) continue; // not smart card cert again
  if( rsa.CspKeyContainerInfo.HardwareDevice ) // sure - smartcard
  {
     // inspect rsa.CspKeyContainerInfo.KeyContainerName Property
     // or rsa.CspKeyContainerInfo.ProviderName (your smartcard provider, such as 
     // "Schlumberger Cryptographic Service Provider" for Schlumberger Cryptoflex 4K
     // card, etc
     var name = cert.Name;
     rsa.SignData(); // to confirm presence of private key - to finally authenticate
  }
}

Display RSS Feed in your website with PHP

The following code will help you to easily integrate RSS feeds from another blog in your website:

In the first step we will create a DOM DOCUMENT into which we will load the rss feed.

$rss = new DOMDocument();
$rss->load('http://wordpress.org/news/feed/');    //Change this to the url you need.


Then from the array we will take out certain elements which we need to display in our site.


$feed = array();
foreach ($rss->getElementsByTagName('item') as $node) {
$item = array ( 
'title' => $node->getElementsByTagName('title')->item(0)->nodeValue,
'desc' => $node->getElementsByTagName('description')->item(0)->nodeValue,
'link' => $node->getElementsByTagName('link')->item(0)->nodeValue,
'date' => $node->getElementsByTagName('pubDate')->item(0)->nodeValue,
);
array_push($feed, $item);
}


Now we set 5 posts to display initially. You can change the limit by changing the value of the $limit variable.

$limit = 5;
for($x=0;$x<$limit;$x++) {
$title = str_replace(' & ', ' &amp; ', $feed[$x]['title']);
$link = $feed[$x]['link'];
$description = $feed[$x]['desc'];
$date = date('l F d, Y', strtotime($feed[$x]['date']));
echo '<p><strong><a href="'.$link.'" title="'.$title.'">'.$title.'</a></strong><br />';
echo '<small><em>Posted on '.$date.'</em></small></p>';
echo '<p>'.$description.'</p>';
}


Put all this code together and you can see the RSS feeds displayed in your website :)

Wednesday, 24 April 2013

Prestashop Payment logo block not seen even after positioned to right column

There will be 2 reasons for this issue:

1) The payment logo will be shown only if the module is linked to a cms link. For this go to the payment logo module configuration in the admin side and attach a cms article to it.

2) If your site is in Catalog mode, then this payment logo will not be shown. Because in catalog mode Prestashop means that all payment methods are disabled. Catalog mode can be set to No from Preferences->General .

If both of these things are done then your payment block will be shown correctly. Have a look :)

Tuesday, 23 April 2013

Prestashop ixttheme - How to customize blocks

Got to themes folder /cfg/profile.xml. The text will be in this page. Customize the text you need and you are done.