Breathing Spring

Archive for August, 2008

subtract current date with past date in PHP

No Comments »

August 30th, 2008 Posted 1:01 pm

<?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);

?>

Posted in php

Protected: Beauty is nothing without brains

Enter your password to view comments

August 29th, 2008 Posted 7:03 am

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


Posted in Personal

Div is jumping in joomla on IE

No Comments »

August 25th, 2008 Posted 3:33 am

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

Posted in CSS, Joomla

Justify code in Zend Development Enviroment

No Comments »

August 24th, 2008 Posted 10:46 am

to justify php code “Ctrl + Shift + F”

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

Posted in Zend

Registering Component to Database

No Comments »

August 18th, 2008 Posted 8:22 am

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’, ”);

Posted in Joomla

Disabling Tips on Joomla

No Comments »

August 18th, 2008 Posted 8:18 am

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

Posted in Joomla

Jlog in Php

No Comments »

August 17th, 2008 Posted 11:11 am

//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));

Posted in Joomla

add one to mysql field

No Comments »

August 12th, 2008 Posted 9:03 am

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

Posted in mysql

Joomla Creating Functions

No Comments »

August 5th, 2008 Posted 10:18 am

· 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'];

Posted in Joomla

Short Echo If Else Statment

No Comments »

August 3rd, 2008 Posted 8:11 am

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 ;)

Posted in php