subtract current date with past date in PHP

<?php
function subtract_dates($begin_date, $end_date)
{
return round(($end_date – $begin_date) / 86400);
}
$beginDate= mktime(0, 0, 0, 8, 30, 2008);
$currentDate= mktime();
echo subtract_dates($beginDate,$currentDate);

?>

Protected: Beauty is nothing without brains

This post is password protected. To view it please enter your password below:


Div is jumping in joomla on IE

The weirdest thing you could ever see in joomla (and which I havnt seen somewhere else yet)

is the DIV jumping and it caused me to change the whole theme. then I realized after few work that the problem presisted again.

I tried to google and I read smething like if the Div jumps (when you open internet explorer and waiting for one second) it means something is tight and isnt fitting well.

Well I didn’t want to believe at first but then I tried to make the container div wider and voala! it worked.

Hope this will work for you too.

CSS can be a pain or a real pain espiceally for those who use IE

Justify code in Zend Development Enviroment

to justify php code “Ctrl + Shift + F”

though it doesnt work for the html code but it help tones

Registering Component to Database

using phpmyadmin add this query.

this will add the component to the backend list too

INSERT INTO jos_components (name, link, admin_menu_link, admin_menu_alt, ‘option’, admin_menu_img, params) VALUES (‘Reviews’, ‘option=com_reviews’, ‘option=com_reviews’, ‘Manage Reviews’, ‘com_reviews’, ‘js/ThemeOffice/component.png’, ”);

Disabling Tips on Joomla

Kinda cheesy but there is no direct way to disable tips on the site.

to remove tips you have to delete the current sentence from the document you want
JHTML::_(‘behavior.tooltip’);

now to remove tips from edit icons go to

component\com_content\helpers\icon.php and remove the JHTML::_(‘behavior.tooltip’); from there

Jlog in Php

//we will need joomla log system
jimport(‘joomla.error.log’);

$log = & JLog::getInstance();
// write variable int log
$log->addEntry(array(“level” => 0,”status”=> 1, “comment” => “helloworld :”.$ret));

add one to mysql field

the long way is

<?php
$sql_query
= mysql_query("SELECT `number` FROM `numbers` WHERE `pageid` = '$pageid'", $link);
while(
$rs = mysql_fetch_array($sql_query)) {
$num = $rs[0] + 1;
}
$sql_query = "UPDATE `numbers` SET `number` = '$num' WHERE `pageid` = '$pageid'";
if(
mysql_query($sql_query)) {
echo
"Record updated successfully";
}
?>

the short way

UPDATE table SET foo = foo +1 WHERE bar = x

Joomla Creating Functions

· To add any function you should add it to the controller of the component

class UserController extends JController

{

function display()

{

> parent::display();

}

}

· to call function in default.php

defined(‘_JEXEC’) or die(‘Restricted access’);

define(‘JPATH_BASE’, dirname(__FILE__) );

require_once (JPATH_COMPONENT.DS.’controller.php’);

UserController::functionName ();

· Make Ajax Call

index.php?option=com_user&format=raw&view=register&task=cities

· to make database connection inside a function

$database = JFactory::getDBO();

$lists = array();

$query = “SELECT * FROM #__country”;

$database->setQuery($query);

$myQuery=$database->query();

$i=0;

while($myRow = mysql_fetch_array($myQuery)){

$country[$i]['Code'] = $myRow['Code'];

$country[$i]['Name'] = $myRow['Name'];

$i++;

}

· To create a list box from the Database array result

$lists['country'] = JHTML::_(’select.genericList’,

$country, ‘country’, ‘class=”inputbox” onChange=”getCity(this.value)” style=”width:200px”‘. ”, ‘Code’,

‘Name’, $row->country);

echo $lists['country'];

Short Echo If Else Statment

there are two ways of doing short echo statment

<?php echo condition? “right” : “left”;?>

I beleive the above way is the best because it has standards, I heard from a friend that <?php is very important. I know he is a geek about making things super perfect but anyways , I go with it.

There is a shorter version which I dont prefer

<?= echo condition? “right” : “left”;?>

though both work but the first one is more right to me and to my computer geek friend ;)

Return top

INFORMATION

Change this sentence and title from admin Theme option page.