Getting Started With CakePHP


Why CakePHP?

CakePHP is an open-source framework for PHP intended to make developing, deploying and maintaining applications much easier. CakePHP offers many useful design patterns, such as the Model-View-Controller pattern..

  • Model-View-Controller layout.
  • Easy CRUD (Create, Read, Update and Delete) database interaction.
  • Scaffolding to save production time.
  • Search Engine Friendly URLS.

1) Download The Framework:

Before you start developing with CakePHP you will need your own copy of the framework uploaded to your server. Visit CakePHP.org and click the large “Download” button. Make sure to download the stable release and not the release candidate.

It will continue in next post.

Working with URL aliases in Drupal 7


Drupal allows you to further customize your website by setting up search engine optimized URLs called aliases. In this tutorial, I’ll explain further what URL aliases are and how you can use them in your Drupal 7 website.

What are URL Aliases

URL aliases allow you to provide a more understandable URL to content such as pages and articles in Drupal..

How to enable URL Aliases in Drupal 7

    1. Login into your Drupal Site
    2. Go to Configuration >> Search and Meta Data >> URL Aliases
    3. Click Add alias

drupal_url_alias_3

  1. Fill in the Existing system path and the Path alias
  2. Click Save.
That’s all ..  Check your url …

Redirect a users to another page using PHP


You can use a simple PHP script to redirect a user from the page they entered to a different web page.
Using this method, they can be seamlessly transfered to the new page without having to click a link to continue.
Benefits:
  • Users are redirected quickly and seamlessly.
  • When using the ‘Back’ button, the user is taken to the last viewed page, not the redirect page.
  • Works on all browsers.

Coding:

<?php

header( ‘Location: http://www.yoursite.com/new_page.html&#8217; ) ;

?>

That’s all.. Check it..

Template your site using PHP


I hope all that this post will help to maintain our php scripts in our projects..

This is very simple to follow..

What it does?

When every page of your website follows the same design theme, it is often easiest to create a template for the site. The specific pages of the site only hold their content and not their design. This makes design changes easy, as they take place on all the pages at once, and there is no need to individually update specific pages.

Steps :

1) The first thing you need to create a file called header.php . In this file you will hold all your page design that comes before  your content

  1. <html> <head><title>My Site</title></head> <body> <h2>My Site Title</h2><p> your content goes here........... <hr>
    2)Next we need to make a file called footer.php. This file will contain all of the site design information that goes below the content
    <hr>
     <small>Copyright 2008 My Site</small><br>
    1.  </body> </html>
      3)Finally you need to create the content pages for your site. In this file you will:
      full script:
       <?php include 'header.php'; ?>
      1. <b>Sub-Page Title</b><p> Here is the specific content of this page....<br> <?php include 'footer.php'; ?>
      Note:
       Remember to save all your files with the .php extension.
       
That’s all… follow this kind of template while developing web sites ..

Jquery program switch button


Already we saw some fantastic scripts using jquery,

I.m happy to share another one script in jquery..

This script shows an output look like real switch (on/off)..

To do this, we need one js lib file and one switch image..

Lets”s start.

Coding:

<html>
<head>
<title>jQuery UI Switch</title>
<link href=”../style.css” rel=”stylesheet” type=”text/css” />

<style>

#container{background:#ebebeb;}

.switch{
border:none;
background:left no-repeat;
width:105px;
height:46px;
padding:0;
margin:0;
}

.on, .off{
width:50px;
height:40px;
display:inline-block;
cursor:pointer;
}

.result{display:none; margin-top:5px; font-size:14px; color:#333;}
.result span{color:#C03; font-weight:700;}

</style>

<script src=”https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js&#8221; type=”text/javascript”></script>

<script type=”text/javascript”>

$(document).ready(function(){

$(‘.switch’).css(‘background’, ‘url(“switch.png”)’);
$(‘.on_off’).css(‘display’,’none’);
$(‘.on, .off’).css(‘text-indent’,’10000px’);

$(“input[name=on_off]“).change(function() {
var button = $(this).val();

if(button == ‘off’){ $(‘.switch’).css(‘background-position’, ‘right’); }
if(button == ‘on’){ $(‘.switch’).css(‘background-position’, ‘left’); }

$(‘.result span’).html(button);
$(‘.result’).fadeIn();

});

});

</script>
</head>

<body>

 

<form action=”” method=”get”>

<fieldset class=”switch”>
<label class=”off”>Off<input type=”radio” class=”on_off” name=”on_off” value=”off”/></label>
<label class=”on”>On<input type=”radio” class=”on_off” name=”on_off” value=”on”/></label>
</fieldset>

<input type=”submit” value=”Submit”/>

</form>

<div class=”result”>The switch is: <span>on</span></div>
</body>
</html>

 

Output:

when we click ON, the msg will be displayed The switch is:on

when we click off, the msg will be displayed The switch is:off

 

keyup function in Jquery


This post shows u that how to use keyup () in jquery.

Let’s us take username and password example.

Consider . the username length should > 4, also password length should > 6.

while we give the value for username that < 4, it shows the error message “username is too short“, then we give correct length value, automatically the error message will be disappear..

same for password field..

Coding:

<script type = “text/javascript” src=”jquery.js”> </script>
<script>
$(document).ready(function(){
$(“#txt_username”).keyup(function()
{
$(“#username_warning”).html(“”);
if ($(“#txt_username”).val().length < 4) {
$(“#username_warning”).html(“Username is too short”);
}
});

$(“#txt_password”).keyup(function()
{

$(“#password_warning”).html(“”);

if ($(“#txt_password”).val().length < 6) {
$(“#password_warning”).html(“Password is too short”); }
});
});
</script>
<body>
<b>Username:</b>
<i>Username must be at least 4 characters in length</i>
<input type=”text” id=”txt_username” name=”username”> <br><br>
<span id=”username_warning” style=”color:red”></span> <br><br>
<b>Password:</b>
<i>Password must be at least 6 characters in length</i><br>
<input type=”password” id=”txt_password” name=”password”>
<span id=”password_warning” style=”color:red”></span>
</body>

 

Output:

 

Simple Sign in Pop up using jquery


Hi,

This is another fantastic concept using jquery.

This is done by toggle() in jquery. we can also the function as our desire.

Coding:

<script type=”text/javascript” src=”http://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js”></script&gt;
<script type = “text/javascript”>
$(document).ready(function()
{
$(“.sign”).click(function()
{
$(“#sign_box”).toggle();
//return false;
});
});
</script>
</head>
<body>

<div> <a href = “#” class = “sign”> Sign In </a> </div>
<div id = “sign_box”>
<form method=”post” action=””>
<label>UserName
<input type=”text” name=”usr”/></label>
<label>Password
<input type=’password’ name=”pwd”/></label>
<input type=”submit” value=” Sing In “/>
</form>
</div>

</body>

Desing Ur Html/css code as ur wish.

Output:

(when you click the singin link it shows the following output)

 

 

Give colors to table cells


Hi,

This is very basic exapmle for css usage..

Let’s look,

create a db and table for display the values in table format.

Coding:

<?php

mysql_connect(“localhost”, “root”, “Iroot054″)or die(“cannot connect”);
mysql_select_db(“mani_color”)or die(“cannot select DB”);

$sql=”SELECT * FROM color”;
$result=mysql_query($sql);

// Define $color=1
$color=”1″;

echo ‘<table width=”400″ border=”1″ align=”center” cellpadding=”2″ cellspacing=”0″>’;
while($rows=mysql_fetch_array($result))
{

// If $color==1 table row color = #FFC600
if($color==1)
{
echo “<tr bgcolor=’#FFC600′>
<td>”.$rows['id'].”</td><td>”.$rows['firstname'].”</td><td>”.$rows['lastname'].”</td>
</tr>”;
// Set $color==2, for switching to other color
$color=”2″;
}

// When $color not equal 1, use this table row color
else
{
echo “<tr bgcolor=’#C6FF00′>
<td>”.$rows['id'].”</td><td>”.$rows['firstname'].”</td><td>”.$rows['lastname'].”</td>
</tr>”;
// Set $color back to 1
$color=”1″;
}

}
echo ‘</table>’;
mysql_close();
?>

Output:

 

Simple Calender Using jquery


Here is the fantastic jquery code for simple calender.

This is used for entering the date values for many purposes such as dob,expiry date.

when we will click the textbox, it shows the datepicker to select the date values.

we need two jquery calender js library files

jquery.1.4.2.js, jsDatePick.jquery.min.1.3.js,  jsDatePick_ltr.min.css

Coding:

<html>
<head>

<title>Javascript example</title>

<link rel=”stylesheet” type=”text/css” media=”all” href=”jsDatePick_ltr.min.css” />

<script type=”text/javascript” src=”jquery.1.4.2.js”></script>
<script type=”text/javascript” src=”jsDatePick.jquery.min.1.3.js”></script>

<script type=”text/javascript”>
window.onload = function(){
new JsDatePick({
useMode:2,
target:”inputField”,
dateFormat:”%d-%M-%Y”
});
};
</script>
</head>
<body>
<input type=”text” size=”12″ id=”inputField” />
</body>
</html>

 

Output:

Zoom the value using jquery..


Another Interesting Concept using jquery..

this is very simple one. Let’s start.

To do this, we need jquery library file

we can add it in two ways

Recommended version: just refer direct link from library site

ex: <script type=”text/javascript” src=”http://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js”></script&gt;

Downloaded Version: download the library file and put it into ur folder

ex: /zoom(folder name)/jquery.js

/zoom(folder name)/zoom.html

First list out the values in select box.. Give one id to select box to get values for zooming.

Coding:(zoom.html)

<html>
<head>
<script type=”text/javascript” src=”http://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js”></script&gt;
<script type=”text/javascript”>
$(document).ready(function()
{
$(“#zoom”).change(function()
{
var size = $(this).val();
$(“#main”).css(‘font-size’, size + ‘px’);
return false;
});
});
</script>
</head>
<body>
<select id = “zoom”>
<option value=”25″>2 </option>
<option value=”50″>4 </option>
<option value=”75″>6 </option>
<option value=”100″>8 </option>
<option value=”150″>10 </option>
<ption value=”200″>12 </option>
</select>
<div id=”main”>
Zoom Effects using Jquery and css.
</div>
</body>
</html>

 

That’s all. Check Ur output..

Thankz ..

Screenshot:

 

 

« Older entries

Follow

Get every new post delivered to your Inbox.