Archive for July 1st, 2008

Password Checker Jquery

this article is taken from :

http://simplythebest.net/scripts/ajax/ajax_password_strength.html

AUTHOR: Digital Spaghetti
TYPE: Open Source MIT License
BROWSERS: JavaScript enabled IE 6.0+, FF 1.5+, Safari 2.0+, Opera 9.0+

To install the script on your Web page follow these instructions:

1) Download this ZIP file with jQuery 1.2.1 and jquery.pstrength-min.1.2.js. Unpack the files and upload both to your server.

2) Insert this anywhere before the password field on the page:

<script type=”text/javascript” src=”js/jquery.js”></script> // adjust the path as is required
<script type=”text/javascript” src=”js/jquery.pstrength-min.1.2.js”>
</script>
<script type=”text/javascript”>
$(function() {
$(‘.password’).pstrength();
});
</script>

3) Insert class=”password” into your input box tag to identify a password box:

<INPUT class=”password” type=password name=”Password”>

4) Insert these tags into your CSS and modify as is needed:

.password {
font-size : 12px;
border : 1px solid #cc9933;
width : 200px;
font-family : arial, sans-serif;
}
.pstrength-minchar {
font-size : 10px;
}

You can adjust a few more settings inside the jquery.pstrength-min.1.2.js script, such as messages, length/height of the bar, and so forth.

Connecting Joomla to database

preparing the query

// Get a database object
$db = JFactory::getDBO();

$query = "SELECT * FROM #__example_table WHERE id = 999999";
$db->setQuery($query);

of course using the Database

Basic Query Execution

- query (This should be user after Set Query if you want to use getNumRows)

Query Execution Information

- getAffectedRows
-explain
-insertid

Insert Query Execution
-insertObject

Single Value Result

-loadResult

Single Row Results

-loadObject
-loadRow
-loadResultArray

Multi-Row Results

-loadObjectList
-loadRowList
-loadAssocList

Misc Result Set Methods

-getNumRows

a nice code would go like

$database = JFactory::getDBO();
$user_name=$_POST['username'];
$query = "SELECT * FROM #__users";
$database->setQuery($query);
$existing_users=$database->loadResultArray();
if (in_array($user_name, $existing_users)) {.. do something }
            

Transparent PNG on IE

Transparent PNG on Internet explorer can be a bit painful but here is a code that can somehow solve the problem on IE6 and earlier (didn’t try it on a version earlier than IE6 honestly)

<SPAN
style=”DISPLAY: inline-block; FILTER: progid:DXImageTransform.Microsoft.AlphaImageLoader(src=’images/my-image.png’); WIDTH: 120px; HEIGHT: 74px”><IMG
style=”FILTER: progid:DXImageTransform.Microsoft.Alpha(opacity=0)” height=74
src=”images/my-image.png” width=120></SPAN>

Class ‘JFactory’ not found

yes the first thing that happened to when I tried to connect joomla page to database was this line. and I couldnt figure our what happened until I realized that I cant make a raw php page and make a connection to database usually I should set all php into the controller.php for the component in a function and if I want to request that function the URL should go in something like :

http://localhost/joomla/index.php?option=com_user&format=raw&view=register&task=user_availability

- option is the current component
- raw is to request a plain page without the template design
- view : is what you are currently viewing
- task : is the function from the controller you want to run

Return top

INFORMATION

Change this sentence and title from admin Theme option page.