Wednesday, 28 September 2011

In operator in mysql

If you want to select id values of 1,2,3 in same query we use IN operator in MySQL


Table Name : user

Id    LastName
1      Value1 
2      Value2
3      Value3 
4      Value4


SELECT * FROM `user` WHERE `Id` =1;

Id    LastName
1       Value1

It select only one value.

By using IN operator

SELECT * FROM `user` WHERE `Id` IN ('1','2','3');

Id    LastName
1      Value1 
2      Value2
3      Value3

SELECT * FROM `user` WHERE `Id` IN ('1','2','10');

In this query Id 10 is not in the table user

So output like this


Id    LastName
1      Value1 
2      Value2


Tuesday, 27 September 2011

Hide after current date in jquery datepicker


If use date picker for Date of birth, need to hide after current date in date picker.
In jquery date picker maxDate is user to hide the dates after current date.

Assign maxDate to current date.

<script type="text/javascript">
<!--

var currentTime = new Date()
var month = currentTime.getMonth() + 1
var day = currentTime.getDate()
var year = currentTime.getFullYear()

$(document).ready(function(){
    $('#DOB1').datepick({
    yearRange: '-90:+10',
    dateFormat: 'mm/dd/yyyy',
    maxDate: 'month/day/year',
    altField: '#DOB1_alt',
    showTrigger: '<img src="images/calendar.gif" alt="Popup" class="trigger">',
    onSelect: function(dates) {
        
    var date = dates[0];
    $('#DOB1_alt').val(date);
    }
    });
    });  

//-->
</script></div>

Monday, 26 September 2011

How get elgg base path

In elgg the global config variable is used
following code is used to get elgg base path

<?php
  global $CONFIG;
  echo $CONFIG->path;
?> 

Sunday, 25 September 2011

Remove submitted by admin in drupal

move the following global setting page in admin
Site bulding -> Themes -> Configure -> Global settings
Disable Post information in "Display post information on"

Friday, 16 September 2011

Product image upload problem in magento 1.6


1. Download prototype.js version 1.6.0.3
2. Go to Magento/js/prototype –  here rename prototype.js with old_prototype.js
3. Then copy downloaded prototype.js in Magento/js/prototype
4. In the /app/etc/config.xml file change the initStatements node from:

<initStatements>SET NAMES utf8</initStatements>
to:
<initStatements>SET NAMES utf8; SET FOREIGN_KEY_CHECKS=0; SET UNIQUE_CHECKS=0;</initStatements>

Flush the cache and then you can upload image for products.

Reference: http://blog.magentoconnect.us/image-upload-problemissue-magento-1-6/

Wednesday, 14 September 2011

Remove Riverdashboard "All" tab in elgg

Follow below 2 steps to remove "All" tab in elgg riverdashboard

Setp 1:

Open the nav.php file in riverdashboard plugin
>> elgg-root\mod\riverdashboard\views\default\riverdashboard\nav.php
$allselect = '';
$friendsselect = '';
$mineselect = '';
switch($vars['orient']) {
    case '':
        $allselect = 'class="selected"';
        break;
    case 'friends':
        $friendsselect = 'class="selected"';
        break;
    case 'mine':
        $mineselect = 'class="selected"';
        break;
}

?>

<?php
if (isloggedin()) {
?>
    <div id="elgg_horizontal_tabbed_nav">
        <ul>
            <li <?php echo $allselect; ?> ><a onclick="javascript:$('#river_container').load('<?php echo $vars['url']; ?>mod/riverdashboard/?content=<?php echo $vars['type']; ?>,<?php echo $vars['subtype']; ?>&amp;callback=true'); return false;" href="?display="><?php echo elgg_echo('all'); ?></a></li>
            <li <?php echo $friendsselect; ?> ><a onclick="javascript:$('#river_container').load('<?php echo $vars['url']; ?>mod/riverdashboard/?display=friends&amp;content=<?php echo $vars['type']; ?>,<?php echo $vars['subtype']; ?>&amp;callback=true'); return false;" href="?display=friends"><?php echo elgg_echo('friends'); ?></a></li>
            <li <?php echo $mineselect; ?> ><a onclick="javascript:$('#river_container').load('<?php echo $vars['url']; ?>mod/riverdashboard/?display=mine&amp;content=<?php echo $vars['type']; ?>,<?php echo $vars['subtype']; ?>&amp;callback=true'); return false;" href="?display=mine"><?php echo elgg_echo('mine'); ?></a></li>
        </ul>
    </div>
<?php
}
?>



Remove above lines and paste following lines in nav.php file

$friendsselect = '';
$mineselect = '';
switch($vars['orient']) {
    case '':
         $friendsselect = 'class="selected"';
        break;
    case 'friends':
        $friendsselect = 'class="selected"';
        break;
    case 'mine':
        $mineselect = 'class="selected"';
        break;
}

?>

<?php
if (isloggedin()) {
?>
    <div id="elgg_horizontal_tabbed_nav">
        <ul>
           <li <?php echo $friendsselect; ?> ><a onclick="javascript:$('#river_container').load('<?php echo $vars['url']; ?>mod/riverdashboard/?display=friends&amp;content=<?php echo $vars['type']; ?>,<?php echo $vars['subtype']; ?>&amp;callback=true'); return false;" href="?display=friends"><?php echo elgg_echo('friends'); ?></a></li>
            <li <?php echo $mineselect; ?> ><a onclick="javascript:$('#river_container').load('<?php echo $vars['url']; ?>mod/riverdashboard/?display=mine&amp;content=<?php echo $vars['type']; ?>,<?php echo $vars['subtype']; ?>&amp;callback=true'); return false;" href="?display=mine"><?php echo elgg_echo('mine'); ?></a></li>
        </ul>
    </div>
<?php
}
?>
Step 2:

 Open the index.php file in riverdashboard plugin
switch($orient) {
    case 'mine':
        $subject_guid = get_loggedin_userid();
        $relationship_type = '';
        break;
    case 'friends':
        $subject_guid = get_loggedin_userid();
        $relationship_type = 'friend';
        break;
    default:
        $subject_guid = 0;
        $relationship_type = '';
        break;
}


Remove above lines and paste following lines in riverdashboard index.php file


 switch($orient) {
    case 'mine':
        $subject_guid = get_loggedin_userid();
        $relationship_type = '';
        break;
    case 'friends':
        $subject_guid = get_loggedin_userid();
        $relationship_type = 'friend';
        break;
    default:
        $subject_guid = get_loggedin_userid();;
        $relationship_type = 'friend';
        break;
}

Disable the spotlight section in elgg

In pageshells file >>> elggroot/views/default/pageshells/pageshells.php

Comment the following line

    <?php  echo elgg_view('page_elements/spotlight', $vars); ?>

<?php
if(isloggedin()){
?>
    <!-- spotlight -->
   <?php //echo elgg_view('page_elements/spotlight', $vars); ?>
<?php
}
?>


Note: If you enable new theme edit the above line in themes views/default/pageshells/pageshells.php file

Tuesday, 13 September 2011

Make your social network using ELGG

Elgg is a social network tool made by PHP and Mysql


Tuesday, 6 September 2011

List the admin menu in drupal

The following code use to display all the menu items in drupal

In user.module file

function user_menu() {

$items['admin/user'] = array(
'title' => 'User management',
'description' => "Manage your site's users, groups and access to site features.",
'position' => 'left',
'page callback' => 'system_admin_menu_block_page',
'access arguments' => array('access administration pages'),
'file' => 'system.admin.inc',
'file path' => drupal_get_path('module', 'system'),
'weight' => 3,
);

}
In system.admin.inc file

function system_admin_menu_block_page() {
$item = menu_get_item();
if ($content = system_admin_menu_block($item)) {
$output = theme('admin_block_content', $content);
}
else {
$output = t('You do not have any administrative items.');
}
return $output;
}
The same module we display our custom module menus

Sunday, 4 September 2011

Create different page templates depending on the current path in drupal

In drupal default template is page.tpl.php.
Drupal check the available template for following order it use the first available template for the current page.
 
1. http://www.mysite.com/node/22
This URL is encountered drupal will check for available templates in the following order.

page-node-22.tpl.php

page-node.tpl.php

page.tpl.php

2. http://www.mysite.com/node/22/edit 
Similarly

page-node-edit.tpl.php

page-node-22.tpl.php

page-node.tpl.php

page.tpl.php

3.  http://www.mysite.com/calendar


page-calendar.tpl.php

page.tpl.php


If you are using URL alias like  http://www.mysite.com/node/2 is http://www.mysite.com/about
To check alias for node in URL aliases->list


Following order is used to check for templates.

page-node-2.tpl.php

page-node.tpl.php

page.tpl.php
 

Friday, 2 September 2011

Convert HTML template to joomla template

Joomla is one of the best cms.

Joomla Template directory structure:

  • index.php
  • component.php
  • template.css
  • templateDetails.xml
  • template_thumbnail.ext ( .jpg, .png, .gif )
The basic index.php file create from following video

 



Create page.tpl for calendar/* all url in drupal 6

calendar for default  page.tpl

Add following function in template.php.
After create page-calendar.tpl.php file in theme folder.
Clear cache and check it.


<?php
function themeName_preprocess_page(&$vars) {
    if (arg(0) == 'calender'){
            $vars['template_files'][] = 'page-calendar';
    }
} 
?> 

 Calendar display using page-calendar.tpl.php ( without right and left side )

Thursday, 1 September 2011

Creating Slideshow in Drupal

Following modules are used to create image slideshow
1. CCK,
2. Views
3. Views Slideshow
4. ImageCache .