Thursday, 1 March 2012

drupal 6 basic form , create form in drupal

<?php
function test_myform($form_state) {
// Access log settings:
$options = array('1' => t('Enabled'), '0' => t('Disabled'));
$form['access'] = array(
'#type' => 'fieldset',
'#title' => t('Access log settings'),
'#tree' => TRUE,
);
$form['access']['log'] = array(
'#type' => 'radios',
'#title' => t('Log'),
'#default_value' =>  variable_get('log', 0),
'#options' => $options,
'#description' => t('The log.'),
);
$period = drupal_map_assoc(array(3600, 10800, 21600, 32400, 43200, 86400, 172800, 259200, 604800, 1209600, 2419200, 4838400, 9676800), 'format_interval');
$form['access']['timer'] = array(
'#type' => 'select',
'#title' => t('Discard logs older than'),
'#default_value' => variable_get('timer', 259200),
'#options' => $period,
'#description' => t('The timer.'),
);
// Description
$form['details'] = array(
'#type' => 'fieldset',
'#title' => t('Details'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['details']['description'] = array(
'#type' => 'textarea',
'#title' => t('Describe it'),
'#default_value' =>  variable_get('description', ''),
'#cols' => 60,
'#rows' => 5,
'#description' => t('Log description.'),
);
$form['details']['admin'] = array(
'#type' => 'checkbox',
'#title' => t('Only admin can view'),
'#default_value' => variable_get('admin', 0),
);
$form['name'] = array(
'#type' => 'textfield',
'#title' => t('Name'),
'#size' => 30,
'#maxlength' => 64,
'#description' => t('Enter the name for this group of settings'),
);
$form['hidden'] = array('#type' => 'value', '#value' => 'is_it_here');
$form['submit'] = array('#type' => 'submit', '#value' => t('Save'));
return $form;
}
function test_page() {
return drupal_get_form(‘test_myform’);
}
?>

Tuesday, 17 January 2012

joomla add script and css in module

$document =& JFactory::getDocument();
$document->addStyleSheet(JURI::root().'media/system/css/calendar.css');
$document->addScript(JURI::root().'media/system/js/calendar_shift1.js');
$document->addScript(JURI::root().'media/system/js/validation.js');

joomla default error message popup, joomla error message popup , joomla username password not matching error message

ADD in head



 <?php
JHTML::_('behavior.mootools');
JHTML::_('behavior.modal');
?>
<?php
if ($this->getBuffer('message')) : ?>
<script type="text/javascript">
window.addEvent('domready', function() {
var myel = new Element('a',{'href':'#error_info'});
SqueezeBox.fromElement(myel,{
handler:'adopt',
adopt:'error_info',
});
});
</script>
<?php endif; ?>


ADD after body

<div style="display:none;">
<div id="error_info"><jdoc:include type="message" />
</div>

change password(admin) drupal

UPDATE users SET pass = MD5('newpassword') WHERE uid=1

Thursday, 12 January 2012

redirect a site on www using .htaccess

RewriteEngine On
RewriteCond %{HTTP_HOST} !^(www\.urbankingsinc\.com)?$
RewriteRule (.*) http://www.urbankingsinc.com/store/$1 [R=301,L]

Monday, 24 October 2011

javascript for conformation on deleting


<script LANGUAGE="JavaScript">
<!--
function confirmSubmit(ttt,id) {
var msg = "Are you sure you want to delete the data ? " + ttt + " - ID= "+id;
var agree=confirm(msg);
if (agree)
return true ;
else
return false ;
}
// -->
</script>



<td><a onClick="return confirmSubmit('<?php echo $row['id']; ?>','<?php echo $row['name']; ?>')" href="delete.php?id=<?php echo $row['id']; ?>"><strong>Delete</strong></a></td>

Wednesday, 14 September 2011

get image upload path for joomla

$folderpath = JPATH_SITE.DS.'components' . DS . 'com_virtuemart' . DS . 'shop_image'. DS .'product/';Barefoot: A Novel