Tuesday 23 July 2013

Create Facebook comment and Like button for each page ( each Link, each Product)

Create Like Button
- Go to https://developers.facebook.com/docs/reference/plugins/like/
- Clear URL to Like and choice some options by yourself.
- Press Get Code and paste those code on your source code.

Create Comment Facebook
- Go to https://developers.facebook.com/docs/reference/plugins/comments/
- Clear URL to comment on and choice some options by yourself
- Press Get Code and paste those code on your source code with some changes.
- Include code
data-href="http://yourweb.com<?=$_SERVER['REQUEST_URI']?>"
 into this code:
<div class="fb-comments" data-width="470" data-num-posts="10"></div>
This is the final code to put comment box to. Example your website is http://bantudong.com
<div class="fb-comments" data-href="http://bantudong.com<?=$_SERVER['REQUEST_URI']?>" data-width="470" data-num-posts="10"></div>

Sunday 21 July 2013

Correct Facebook share thumbnail and description - Joomla 2.5 & Virtuemart 2.0

This is a great way to add Open Graph meta tags to the flypage of Virtuemart, to specify the image used by Facebook like, share, send, etc buttons 
I have made some little improvements to your code though, so that it will not be necessary to hard code the domain name of your site and also i added the og::site_name meta tag.
Also I wanted the generated html code to be valid (http://validator.w3.org/) so i had to use addCustomTag() instead of setMetaData() to generate "meta property" instead of "meta name" .

Code: 
$og_type = 'article';
$og_url = JURI::current();
$og_image =  JRoute::_(JURI::base().$this->product->images[0]->file_url);
$og_desc = $this->product->product_s_desc;
$og_title = $this->product->product_name;

$app =& JFactory::getApplication();
$og_sitename = $app->getCfg('sitename');

$doc = JFactory::getDocument();
$doc->addCustomTag('<meta property="og:type" content="article"/>');
$doc->addCustomTag('<meta property="og:url" content="'.$og_url.'"/>');
$doc->addCustomTag('<meta property="og:site_name" content="'.$og_sitename.'"/>');
$doc->addCustomTag('<meta property="og:image" content="'.$og_image.'"/>');
$doc->addCustomTag('<meta property="og:description" content="'.$og_desc.'"/>');
$doc->addCustomTag('<meta property="og:title" content="'.$og_title.'"/>');


This piece of code has to be inserted at the first lines of file "components/com_virtuemart/views/productdetails/tmpl/default.php" just after the line:

Code: 
defined('_JEXEC') or die('Restricted access');
It would be even better if you copy this file at your template directory (folder: templates/my_Joomla_template/html/com_virtuemart/productdetails/) so that it will not be modified by any Virtuemart upgrades.


Check this Change by link:
https://developers.facebook.com/tools/debug

Product sort order on browse/category view - ascending to descending

Problem:
When i show virtuemart home page the product will show in ASC order , (the oldest first) how can i change this with the newest first ?
In the configuration i use date_created_on , if i press this option (in selectbox) is correct but i would that was by default

Solution:
change file: /administrator/components/com_virtuemart/models/product.php
Find the following code:
Code: [Select]
/* invert order value set*/
if ($order =='ASC') {
$orderlink ='&order=DESC';
$orderTxt = JText::_('COM_VIRTUEMART_SEARCH_ORDER_DESC');
} else {
$orderTxt = JText::_('COM_VIRTUEMART_SEARCH_ORDER_ASC');
$orderlink ='';
}

and just switch the order. Be AWARE that this will change all your default sort by to descend.

ALSO, Do you have SEF on or off?

if SEF on, then go to /components/com_virtuemart/router.php.
Inside the file, move the following:
Code: [Select]
if ( isset($query['order']) ) {
if ($query['order'] =='DESC') $segments[] = $helper->lang('orderDesc') ;
unset($query['order']);
}
to after 
Code: [Select]
if ( isset($query['orderby']) ) {
$segments[] = $helper->lang('by').','.$helper->lang( $query['orderby']) ;
unset($query['orderby']);
}

Wednesday 17 July 2013

Use Module Title as link in Joomla 1.6 , 1.7 , 2.5

1 – Open your module .xml file  example - modules/mod_articles_news/mod_articles_news.xml
2 –  Add the following line between the first set of <fieldset name=”basic”></fieldset> tags
<field name="title_link" type="text" default="" label="Title link" description="" />
Save your XML file.
3 – Now go to templates/system/html/modules.php open it & find the xhtml function or find this line “ xhtml (divs and font headder tags) ” here you can find this function
function modChrome_xhtml($module, &$params, &$attribs)
{
 if (!empty ($module->content)) : ?>
  <div class="moduletable<?php echo htmlspecialchars($params->get('moduleclass_sfx')); ?>">
  <?php if ($module->showtitle != 0) : ?>
   <h3><?php echo $module->title; ?></h3>
  <?php endif; ?>
   <?php echo $module->content; ?>
  </div>
 <?php endif;
}

& replace with
function modChrome_xhtml($module, &$params, &$attribs)
{
 if (!empty ($module->content)) : ?>
  <div class="moduletable<?php echo htmlspecialchars($params->get('moduleclass_sfx')); ?>">
  <?php if ($module->showtitle != 0) : ?>
   <?php $title_link = $params->get('title_link'); ?>
   <h3><?php if($title_link) { ?> <a href="<?php echo $params->get('title_link');  ?>"> <?php } ?><?php echo $module->title; ?><?php if($title_link) { ?></a><?php } ?></h3>
  <?php endif; ?>
   <?php echo $module->content; ?>
  </div>
 <?php endif;
}

4 – now you have link area in your module basic parameter add your link  :)
Conclusion - Its very simple hack  or trick in joomla i hope in joomla! 3.0 joomla add this feature by default :) if you get any kind of issue or can’t get right result kindly leave your comment or contact with me thanks

Tuesday 16 July 2013

Use sh404SEF to create friendly web link

One of the most way to SEO an webpage is create an friendly web link. With Joomla, we can choice sh404SEF component as a best solution.
This is step by step how to use it.



  1. Download load sh404SEF 4.1.0.1559  here. This version is used for Joomla 2.5 and 3.0
  2. Install this component into your Joomla website


  3. Enter sh404SEF Control Panel by this way: menu Component->sh404sef->Control Panel

  4. At Quick Start tab, choice all are Yes, and Rewriting mode is with .htaccess (mod_rewrite), then Press Start button
  5. Now press Configuration Button at top right and choice tab General->Main. At Character replacements list add more these characters:
    , á|a, à|a, ả|a, ã|a, ạ|a, â|a, ấ|a, ầ|a, ẩ|a, ẫ|a, ậ|a, ă|a, ắ|a, ằ|a, ẳ|a, ẵ|a, ặ|a, đ|d, é|e, è|e, ẻ|e, ẽ|e, ẹ|e, ê|e, ế|e, ề|e, ể|e, ễ|e, ệ|e, í|i, ì|i, ỉ|i, ĩ|i, ị|i, ó|o, ò|o, ỏ|o, õ|o, ọ|o, ô|o, ố|o, ồ|o, ổ|o, ỗ|o, ộ|o, ơ|o, ớ|o, ờ|o, ở|o, ỡ|o, ợ|o, ú|u, ù|u, ủ|u, ũ|u, ụ|u, ư|u, ứ|u, ừ|u, ử|u, ữ|u, ự|u, ý|y, ỳ|y, ỷ|y, ỹ|y, ỵ|y, Á|A, À|A, Ả|A, Ã|A, Ạ|A, Â|A, Ấ|A, Ầ|A, Ẩ|A, Ẫ|A, Ậ|A, Ă|A, Ắ|A, Ằ|A, Ẳ|A, Ẵ|A, Ặ|A, Đ|D, É|E, È|E, Ẻ|E, Ẽ|E, Ẹ|E, Ê|E, Ế|E, Ề|E, Ể|E, Ễ|E, Ệ|E, Í|I, Ì|I, Ỉ|I, Ĩ|I, Ị|I, Ó|O, Ò|O, Ỏ|O, Õ|O, Ọ|O, Ô|O, Ố|O, Ồ|O, Ổ|O, Ỗ|O, Ộ|O, Ơ|O, Ớ|O, Ờ|O, Ở|O, Ỡ|O, Ợ|O, Ú|U, Ù|U, Ủ|U, Ũ|U, Ụ|U, Ư|U, Ứ|U, Ừ|U, Ử|U, Ữ|U, Ự|U, Ý|Y, Ỳ|Y, Ỷ|Y, Ỹ|Y, Ỵ|Y
  6. It has many options, but you can use default.
  7. Go to you File Manager on your hosting, Edit file htaccess.txt - Find code:
        ########## Begin - Joomla! core SEF Section
    #
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} !^/index.php
    RewriteCond %{REQUEST_URI} (/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$ [NC]
    RewriteRule (.*) index.php
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
    #
    ########## End - Joomla! core SEF Section
    
    
    And replace by this code:
    
    
    ########## Begin - Joomla! core SEF Section
    #
    #RewriteCond %{REQUEST_FILENAME} !-f
    #RewriteCond %{REQUEST_FILENAME} !-d
    #RewriteCond %{REQUEST_URI} !^/index.php
    #RewriteCond %{REQUEST_URI} (/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$ [NC]
    #RewriteRule (.*) index.php
    #RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
    #
    ########## End - Joomla! core SEF Section
    #
    ########## Begin - 3rd Party SEF Section
    ############# Use this section if you are using a 3rd party (Non Joomla! core) SEF extension - e.g. OpenSEF, 404_SEF, 404SEFx, SEF Advance, etc
    #
    RewriteCond %{REQUEST_URI} ^(/component/option,com) [NC,OR] ##optional - see notes##
    RewriteCond %{REQUEST_URI} (/|\.htm|\.php|\.html|/[^.]*)$ [NC]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule (.*) index.php
    #
    ########## End - 3rd Party SEF Section
    
    
    
    
  8. Change name of htaccess.txt to .htaccess
  9. Turn off all SEO Setting in Global Configuration of Joomla.
Done. Now you can check you web link again.

Wednesday 10 July 2013

Fix error "Could not create directory" on Joomla

Sometime, Installing an extension we have error about "Could not create directory" like this:

This tutorial will show you how to solve the problem 
"JFolder::create: Could not create directory"
or 
"JFolder::create: Path not in open_basedir paths; Unable to create destination" in Joomla.
Firstly:
If you have tried everything else on your installation (changing the $log_path to ./log, change $tmp_path to ./tmp (in  configuration.php file, chmod folders to 777) and you still can't install any module or component in Joomla, then continue reading.
This solution is helpfull if you can't change the ownership of the files and directories on your server (usually shared hosts) and you don't want to wait for help from your hosting provider.

If it still error or have new error, It means you have to do next step.

First you need to chmod to 777 the following directories:
/administrator/backups/
/administrator/components/
/administrator/language/
/administrator/language/en-GB/
/administrator/modules/
/administrator/templates/
/components/
/language/
/language/en-GB/
/modules/
/plugins/
/plugins/content/
/plugins/editors/
/plugins/editors-xtd/
/plugins/search/
/plugins/system/
/plugins/user/
/plugins/xmlrpc/
/tmp/
/templates/
/cache/
1. Open "your-website.com/libraries/joomla/filesystem" with your default FTP client.
Please make backup of the file first.
2. Download filename "folder.php".
3. Open folder.php in your default text editor
4. Go to line 210
5. Look for:     " if (strpos($path, $test) === 0) { "  and change it to "if (strpos($path, $test) === 1) { "
6. Than look for (line 216):  " if ($inBaseDir == false) { "  and change to  " if ($inBaseDir == true) { "
7. Save your file (folder.php)
8. Upload it to the location "your-website.com/libraries/joomla/filesystem". 

That's it!
No more errors when you want to install any component, plugins, module, etc.. in backend of joomla

Apply Watermark image into Product Image of Virtuemart

Problem: When Creating an shopping website, we would like to apply a watermark image - logo and website name - on every picture of products. It is seem easy by this way: use an watermark program to apply icon on product picture, then upload that picture on hosting. Take a long time if you have over 50 products.
I want to do this work automatically, It means watermark picture will be applied in to all picture (old and new) of website

Solve: I do this work on Joomla 2.5 and Virtuemart 2.0. But I think it is comfortable for every happen load and show Image.
  • Step 1: Create file .htaccess on folder contain image, with Virtuemart 2.0, this folder is <your_domain>/images/stories/virtuemart/product.
    RewriteRule ^(resized)($|/) - [L]
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} -f
    RewriteRule \.(gif|jpeg|jpg|png)$ watermark.php [QSA,NC]
  • Step 2: Create file watermark.php at same folder of .htaccess with content:

    <?php
    // watermark.php
    // Path the the requested file
    $path $_SERVER['DOCUMENT_ROOT'].$_SERVER['REQUEST_URI'];
    // Load the requested image
    $image imagecreatefromstring(file_get_contents($path));$w imagesx($image);$h imagesy($image);
    // Load the watermark image
    $watermark imagecreatefrompng('watermark.png');$ww imagesx($watermark);$wh imagesy($watermark);
    // Merge watermark upon the original image (centred)
    imagecopy($image$watermark, (($w/2)-($ww/2)), (($h/2)-($wh/2)), 00$ww$wh);
    // Send the image
    header('Content-type: image/jpeg');imagejpeg($image,null,95);
    exit();
    ?>
  • Step 3: Create an watermark.png with transparent background and upload to that folder.
Done.
Now you can test all image file in folder <your_domain>/images/stories/virtuemart/product have watermark if you call them on your website

Note: the code line RewriteRule ^(resized)($|/) - [L] in .htaccess file ensure that all thumbnail file in resized folder will be not watermarked. If you want to watermark on both thumbnail and large picture, you can remove that line

Demo


Saturday 6 July 2013

Hide list Catelogy on result Search page format

When we use Virtuemart_search module, list of catelogy will be showed before result list.
Some case, I want to hide this catelogy list and only show result list. This solution I found on internet.

In search module \modules\mod_virtuemart_search\tmpl\default.php  line 4 says:

Code:
<form action="<?php echo JRoute::_('index.php?option=com_virtuemart&view=category&search=true&limitstart=0&virtuemart_category_id='.$category_id )
The result of search is intended to be shown in category view. So, what do we have here? $category_id=0 (parent category!) and sub-categories on top of the default category view, then the list of products (if any), found in our search.

Temporary solution: if we don't need categories in category view, at least in our search result, check if it is a search request. Change line 72 in \components\com_virtuemart\views\category\tmpl\default.php from this:

Code: 
if(!empty($this->category->children)){
to this:

Code:
if(!empty($this->category->children ) && !(boolean)JRequest::getVar('search', false)){

This is my result


How to Show SKU of product in Virtuemart

This is a tip about Joomla and Virtuemart which I found on Internet.

SKU = "Store Keeping Unit". This is an identifier given to each product.
On Virtuemart, you are free to follow any rules to design its value.
If you handle SKUs from other vendors on your store, you may find duplicate values.

In some cases, we want to show this SKU value on product details page, It will be very easy if you know this way:


  1. Find this file on your hosting in order to edit it: <your_site>/components/com_virtuemart/views/productdetails/tmpl/default.php
  2. Choice position you want to show SKU and add this code:
    <?php // Product SKU     ?>
        <h1>
        <?php echo 'SKU: '?>
        <?php echo $this->product->product_sku ?>
        </h1>
  3. You don't need use tag <h1>.
Demo:

Before



After