Thursday, December 30, 2010

Hiding Java Script page error

To remove Java Script page error just put below code block at the end of HTML file.

<script type="text/javascript">
function noErrorMessages () { return true; }
window.onerror = noErrorMessages;
</script>

Wednesday, November 10, 2010

Client side upload image size checking using Java Script

<HTML>
<Head>
<script type="text/javascript">
function disableMe() {
    var node = document.getElementById('file1');
    if (navigator.appName == 'Microsoft Internet Explorer'){
        var oas = new ActiveXObject("Scripting.FileSystemObject");
        var d = document.frm1.file1.value;
        var e = oas.getFile(d);
        var check = e.size;
    } else {
        var check = node.files[0].fileSize;
    }
    if (check > 1200000)
    {
        alert('Your file is to big! ');
        return false;
    }
}
</script>

<form enctype="multipart/form-data" action="upload_file.php" method="post" class="body" name="frm1">
<td><font size='2'><b>Select a file:</b></font> </td><td><input type='file' id='file1' name='file1'></td></tr><tr><td></td><td>
 <input type='submit' value=' Upload File ' id="mybutton" onClick='return disableMe();'>
</form>

Friday, September 10, 2010

How to create Header/Footer Menu in Drupal site

When you create any content from Drupal admin then you can choose "Parent Item" i.e (Primary Links / Secondary Links) from Menu settings tab for that item.

Header Menu

In Drupal theme (page.tpl.php), all parent menu links are available in $primary_links array. You can just loop through the array elements and print all menu items in header.

<?php if ($primary_links){ ?>
<ul>
<?php  
foreach($primary_links as $value){
  echo '<li><a href="'.$base_path . drupal_get_path_alias($value['href']) .'">'.$value['title'].'</a></li>';
}
?>
</ul>
<?php } ?>


Footer Menu

In Drupal theme (page.tpl.php), all secondary menu links are available in $secondary_links array. You can just loop through array elements and print all menu items in footer.

<?php if ($secondary_links){ ?>
<ul>
<?php  
foreach($secondary_links as $value){
   echo '<li><a href="'.$base_path . drupal_get_path_alias($value['href']) .'">'.$value['title'].'</a></li>';
}
?>
</ul>
<?php } ?>

Friday, August 27, 2010

How to insert a Module in Joomla 1.5 Component

To insert joomla module in component , you just need to put this code block in component template file.
Here "moduleposition" is the module position which you will have defined from Joomla Admin Module manager section. Then this will list all modules of that position.

       <?php
            $modules =& JModuleHelper::getModules('moduleposition');
            if(count($modules) > 0){
                foreach ($modules as $module)
                {
                   echo JModuleHelper::renderModule($module);
                }
            }
         ?>

Monday, August 23, 2010

How to remove mootools.js and caption.js from Joomla 1.5

In Joomla 1.5 template file index.php, you just need to put this below code to remove default Joomla JS from page header.

Path : /templates/themename/index.php

<?php
$user =& JFactory::getUser();
if ($user->get('guest') == 1) {
$headerstuff = $this->getHeadData();
$headerstuff['scripts'] = array();
$this->setHeadData($headerstuff); }
?>
<jdoc:include type="head" />

Replace below 2 lines with above code block.


<jdoc:include type="head" />
<?php JHTML::_('behavior.mootools'); ?>

This above code block will remove following lines from page:

/joomla/media/system/js/mootools.js
/joomla/media/system/js/caption.js