Thursday 7 May 2015

Contact form in Wordpress



Contact form in Wordpress


Hello  All,

Mostly Use Contact Form In Web site.

I am Create simple code  for add contact form in wordpress.

It's Only Example No Plugin required. You can also Custimise;

I am create Name,Email,Message Fild in wordpress;

CREATE TABLE IF NOT EXISTS `wp_myphpinformation` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(100) NOT NULL,
  `email` varchar(100) NOT NULL,
  `message` varchar(225) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

I am create this table in my php admin.

Create templete In Wordpress


/*
Template Name: My Custom Page
*/

Copy the page.php of your current theme and change name like contactform.php

After adding a comment and check with your admin this template.


I am here add full Ecample Code Check IT. I hope you like;

it's contactform.php

<?php

/*
Template Name: My Custom Page
*/
?>
<?php get_header(); ?>
<?php
        if (!empty($_POST)) {
        global $wpdb;
            $table = wp_myphpinformation;
            $data = array(
                'name' => $_POST['yourname'],
                'email'    => $_POST['email'],
                'message' =>  $_POST['message']
            );
            $format = array(
                '%s',
                '%s',
                '%s'
            );
            $success=$wpdb->insert( $table, $data, $format );
            
            
            if($success){
            echo 'data has been save' ; 
}
}
else   {
?>
        <form method="post">
       

Contact Me

        <input type="text" name="yourname"/><br />
        <input type="text" name="email"/><br />
        <textarea name="message"></textarea><br />//textarea code
        <input type="submit"/>
        </form>

       <?php }  ?>
       <div class="contact">
       <table>
        <tr>
        <td>Name</td>
        <td>Email</td>
        <td>Message</td>
        </tr>
       <?php 
       
       $results = $wpdb->get_results( 'SELECT * FROM wp_myphpinformation', OBJECT );
       
       foreach($results as $result){?>
        
        <tr>
        <td>php echo $result->name; ?></td>
        <td>php echo $result->email; ?></td>
        <td>php echo $result->message; ?></td>
        </tr>
        
        
        
      <?php }
       
       ?>
       </table>
       </div>

<?php get_footer(); ?>

Monday 4 May 2015

Errors file upload in PHP

Hello

Here Very small errors are found in file upload.

You can find the code for file uploading from the internet  but you can make some mistake.

I Will oberserve you. mostlly mistake in file upload.

1) in form html enctype="multipart/form-data"


<form action="" method="post" enctype="multipart/form-data">
    Select image to upload:
    <input type="file" name="fileToUpload" id="fileToUpload"/>
    <input type="submit" value="Upload Image" name="submit"/>
</form>

when you use input type file then you must write enctype="multipart/form-data"
it's recuired otherwise it can not upload file or get issue or error in file upload code.

2) just check file_uploads = On in your php.ini file.

Friday 1 May 2015

Parallax Scroll and Back to Top Using Jquery

Parallax Scroll and Back to Top Using Jquery


Hello
Here you can create parallax scroll and back to top using jquery.

just you can add jquery in your html 


i am write script here give smaple code then check it your html

here sample code


please check it 

here i  add simple jquery scripy

<script type="text/javascript"&
gt;

jQu
ery( document ).ready(function() {
    
    jQuery('.tryitbtn a').click(function() { 
     if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
      var target = $(this.hash);
      target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
      if (target.length) {
        $('html,body').animate({
          scrollTop: target.offset().top
        }, 1000);
        return false;
      }
    }
  });
    
    jQuery('a.back_t').click(function () {
        //alert('hi');
jQuery('body,html').animate({
scrollTop: 0
}, 800);
return false;
});
  
})
;

</
script>

Monday 27 April 2015

How to Show popular search terms in sidebar Magento

How to Show popular search terms in sidebar Magento


Hello In you need to add popular search in your sidebar.

if you add code this code in local.xml file or catalog.xml file when to add block for side bar.

<block type="catalogsearch/term" after="tags_popular" name="catalogsearch.term" template="catalogsearch/term.phtml"/>

here i am added left sidebar in code

<reference name="left">
   <block type="catalogsearch/term" after="tags_popular" name="catalogsearch.term" template="catalogsearch/term.phtml"/>
   </reference>

Please use it. 

Thursday 23 April 2015

how to get store information in magento?

how to get store information in magento?


Hello Herer Some Function To use how to get store value in your phtml file.

1)

Get Current page URL of Store

Mage::app()->getStore()->getCurrentUrl();

2)

Get store data

Mage::app()->getStore();

3)

Store Id

Mage::app()->getStore()->getStoreId();

4)

Get  Store code

Mage::app()->getStore()->getCode();

5)


Get Website Id

Mage::app()->getStore()->getWebsiteId();


6)

Is Active store get 

Mage::app()->getStore()->getIsActive();

7)


Get Homepage URL of Store

Mage::app()->getStore()->getHomeUrl();








Sunday 19 April 2015

how to get new root category of sub category in magento and display navigation in menu

how to get new root category of sub category in magento


$root_category = Mage::getModel('catalog/category')->load(7); // Put your root category ID here.

  $subcategories = $root_category->getChildren();?>

  

  <ul class="cat_list">
 
  <?php foreach(explode(',',$subcategories) as $subcategory) {

        $category = Mage::getModel('catalog/category')->load($subcategory);?>

echo $category->getName()?></a></li>

 <?php }?>

  </ul>

this will help you new root category get child cateogry check it

if you want to add new root category in your menu then 
just do and follow step

Go to Admin -> Catalog -> Manage Categories -> "Select Category" -> Display Settings -> Is Anchor = "Yes"

Then:

Admin -> System -> Index Management -> "Select All" -> "Reindex data" -> "Submit"

get defualt root category any where

Mage::app()->getStore("default")->getRootCategoryId()

any new root category then

Mage::app()->getStore($storeId)->getRootCategoryId();