Pages

Friday, April 6, 2012

Strip img or HTML tag from HTML

While i was woking with Joomla Easy Blog ran into a problem where i have to get image/image link from the DB result in which all of the blog content was mixed.I used below method for that after a long session with regx and all.Happy coding. And for sure regx never helped me


$html = $row->text;
$base_url = JURI::root();
// $dom->load('test.html'); // if in a file
$dom->loadHTML($html); // if in a string

for ($i=0;
$i<$dom->getElementsByTagName('img')->length;
$i++) {
$sam = $dom->getElementsByTagName('img')->item($i)->getAttribute('src');
echo $base_url$sam ;//use this for image source

}

?>

Wednesday, December 21, 2011

CK Editor Height and Width

You can not specify width and hieght in your input and expect work fine with CKEDITOR.Beacause it wont adjust height and width of CKEDitor

To specify height and width of of a CKEDiTOR

field use this code in your css

.cke_contents{
height: 400px !important;
width: 550px !important;
}

Friday, December 9, 2011

cakephp validation using jquery validator

In my project client was asked to do client side validation.I decided to use jquery validator in my Cakephp project.I tried find out "how to do" with my project..I got to read jquery validator plugin DOC and tried some demo version.After many fat burning session i decided to post in my blog so that starter like me can go through you it and find a solution.

Steps
--------
1.download jquery validator plugin from this link.

2.Copy jquery.validate.js and jquery.js in cake/app/webroot/js folder.

3.Use this code in your view to load script inline in your view

$options = array('inline'=>'inline');
echo $javascript->link('validator/jquery.validate.js',null,$options);

4.Try this was in your view

$(function(){
$('#admin_register').validate({
debug: false,
errorClass: "authError",
errorElement: "span",
rules: {
"data[User][email]": {
required: true,
email: true
},
"data[User][telephone]": {
number: true,
minlength: 10
}
},
highlight: function(element, errorClass) {
$(element).removeClass(errorClass);
}
});
});

5.Your form is going to be something like this.

echo $form->create('User', array('action' => 'admin_register','inputDefaults'=> array('label'=>false),'type' => 'file','id'=>'admin_register'));


POINTS TO GIVE SOME ATTENTION
-------------------------------------------------------------

$('#admin_register').validate({ ----------its using form element's ID .

"data[User][telephone]": {-----------------Give form input field's name attribute as mentioned here.(I made mistake in this section, that is i used data[User][telephone] instead of "data[User][telephone]" )

Saturday, November 26, 2011

Fancy box close after login

One of my friend used fancybox for login.And he could not close fancy box after login.So i tried to help him and guess what i used this code to its completion.

parent.$.fancybox.close(); parent.location.reload(true);exit();

Tuesday, January 25, 2011

starter?

i was really confused about what should i study after my B-Tech.At first was panned to join for JAVA and after that plan got shifted to .NET.And finally i decided to run behind PHP...In my opinion PHP is good scripting language to get started if you are a starter in this field.The advantages are many. I hate to say go back to my previous post and find it out.

you had to have a small idea about the so called javascript and html.If you are familiar with this terms then think that you are doing your PHP.hehehe....

Sunday, January 23, 2011


What is CSS?

  • CSS stands for Cascading Style Sheets
  • Styles define how to display HTML elements
  • Styles were added to HTML 4.0 to solve a problem
  • External Style Sheets can save a lot of work
  • External Style Sheets are stored in CSS files


CSS Saves a Lot of Work!

CSS defines HOW HTML elements are to be displayed.

Styles are normally saved in external .css files. External style sheets enable you to change the appearance and layout of all the pages in a Web site, just by editing one single file!


CSS Syntax

A css synatax have to parts

a sector and one or more decleration.