Thursday, 25 April 2013

Wordpress Integration Help

Steps

1)     wpcontent->themes>Copy 2011folder  and paste then rename that folder like wpdemo after it.
    In admin side->appearance->theme, active wpdemo theme.

2)    Copy All images to images folder and copy css in style.css under default css. if any css is conflict then remove      that default css.

3)    Now open header.php, see where body start,after body whole content copy and paste another page,then copy html content     which is shown in header part that content paste in header.php.


4)    Sitepath (Means path will be in theme like wordpress folder name->wp-content->theme->theme name)

    sitepath==>    <?php echo get_template_directory_uri(); ?>/

5)    For Top Menu
   
    <?php wp_nav_menu( array( 'theme_location' => 'primary' ) ); ?>



6)    Search ==> get_search_form();

7)    Index.php path ==> <?php echo esc_url( home_url( '/' ) ); ?>


8)    create menu like top,footer,left etc....
       
    Appearance->menu

        First create new menu like Main Menu or top menu then set thaat menu to primary menu


9)    Create menus like in top menu about us,services etc...
   
    wpadmin->pages->add pages

    after create add pages then go to appearance->menu and go to pages tab and select menu checkbox and then "add to menu " button and then click on "save menu"


10) For Banner..Thethe image slider
      code for banner==>  <?php if (function_exists('get_thethe_image_slider')) { print get_thethe_image_slider('slider1'); } ?>

   
11)    now footer menu
   
   
    wpcontent->theme->open function.php and create new function  sidebar
   
    eg.

    register_sidebar( array(
    'name' => __( 'Footer Menu', 'twentyeleven' ),
    'id' => 'footermenu',
    'description' => __( 'The sidebar for the optional Showcase Template', 'twentyeleven' ),
    'before_widget' => '<aside id="%1$s" class="widget %2$s">',
    'after_widget' => "</aside>",
    'before_title' => '<h3 class="widget-title">',
    'after_title' => '</h3>',
    ) );

    then save and then go to  admin side appearance->widgets and see in right side "Footer Menu" created.
    then click on "Custom Menu" and drop in "Footer Menu" and the select  menu like "footermenu" and save it.

    After that open footer.php and write code dynamic_sidebar('sidebar name'); means eg. id of register_sidebar function


12)    Remove toolbar on top
    -----------------------
        wp-admin->users->allusers->admin and then remove click toolbar checkbox


13)    if page is frontpage or not so
    is_front_page or is_home

14)    Remove comment in contact us page
    ---------------------------------
    wp-admin->pages->contactus->click quick edit->then remove click checkbox on "Allow comment"


15)    get Side bar
    -------------

    <?php //get_sidebar(); ?>



16)    Content
    ----------
$homecontent = get_posts('numberposts=3&category=6&order=ASC');
foreach( $homecontent as $home ) : setup_postdata($home);

?>

<?php //echo $home->short_content(32); ?>

<?php //echo $home->post_date; ?>
 <?php //echo $home->post_title; ?>
    <div id="specials">
        <div id="more-special"><a href="<?php echo $home->guid; ?>">More</a></div>
      </div>
          
<?php endforeach; ?>  


17)

 <?php

$mylastestnew = get_posts('numberposts=2&category=6&order=DESC');

foreach( $mylastestnew as $news ) : setup_postdata($news);



?>

<?php echo short_content(32); ?>

<span id="news-date"><?php echo $news->post_date; ?></span>

<a href="<?php echo $news->guid; ?>">Read More </a>

<?php endforeach; ?>

18)
<?php echo $post33->post_title; ?>
3:54 PM <?php

$my_id = 56;

$post_id_home = get_post($my_id);

$content = $post_id_home->post_content;

$title = $post_id_home->post_title;

?>


<?php

if (class_exists('CSSDropDownMenu'))

 {

     $myMenu = new CSSDropDownMenu();

     /* Extra options here, like so: $myMenu->orientation="top"; */

     $myMenu->show();

 }

 ?>


<!--start header-cart-->
 <div id=""><a href="http://example.com/products-page/checkout/">
   <!-- name the class anything you like -->  <p>
              <? if (function_exists('wpsc_cart_item_count')) { // checks to see if this function exists
                  if (wpsc_cart_item_count() == 0 || isset($_GET['sessionid'])) { // checks if count is zero or sessionid is set
                      echo "Shopping cart is empty";
                  } 
   elseif (wpsc_cart_item_count() == 1 || isset($_GET['sessionid'])) { // checks if count is one or sessionid is set
                      echo wpsc_cart_item_count(); // this is the function that checks the item count in your cart
   ?>
            item in cart
 <?
                  } else
   {
                      echo wpsc_cart_item_count(); 
   ?>
            items in cart
 <?    }
              } ?>
          </p></a>
   
</div>
<!--close header-cart-->




<?php if (wpsc_cart_item_count()== 0) {
echo "Your shopping cart is empty";
}else {
    echo "Shopping cart :";
?>

<a target="_parent" href="<?php echo get_option('shopping_cart_url'); ?>" title="<?php _e('Checkout', 'wpsc'); ?>" class="gocheckout"><?php printf( _n('%d item', '%d items', wpsc_cart_item_count(), 'wpsc'), wpsc_cart_item_count() );
?></a>

<?php } ?>





//Display Limited Content

$seo_id=138;
 $seo_id= get_post($seo_id);
   
 $seo_content = $seo_id->post_content;
 $seo_limit=380;
 if (strlen($seo_content) > $seo_limit)
     $seo_content = substr($seo_content, 0, strrpos(substr($seo_content, 0, $seo_limit), ' '));



Hi..

First of all--- submit.php ne current active theme ma muki devani.
Ane Action ma theme no path muki devano...

like.

<form action="<?php bloginfo('stylesheet_directory'); ?>/submit.php">
</form>

aathva

<form action="<?php echo site_url() ?>/wp-content/themes/theme-name/submit.php">
</form>

Insert Excel sheet data in mysql dataase using php

First download excel reader.php file

http://code.google.com/p/php-excel-reader/downloads/detail?name=php-excel-reader.zip&can=2&q=


Code 
______

 require_once("config.php");
require_once 'excel_reader_2.php';


    $excelFileName = $_FILES['img_upload']['name'];
    if($excelFileName != "")
    {
   

        $uploadDir = '../uploadexcelfiles/';
        $uploadFile = $uploadDir . $excelFileName ;
        $filename=$_FILES['img_upload']['name'];
        $ext = substr($filename, strpos($filename,'.'), strlen($filename));
   
        if($ext == '.xls')
        {
           
            if (move_uploaded_file($_FILES['img_upload']['tmp_name'], $uploadFile))
            {

                $data = new Spreadsheet_Excel_Reader();
                $data->setOutputEncoding('CP1251');
                $data->read($uploadFile);
                $flag=false;
                $rows=$data->sheets[0]['numRows'];
                $rows -=1;


                    for ($i = 1; $i <= $data->sheets[0]['numRows']; $i++)
                    {
                        $age="";
                        $wins="";
                        $most="";
                        $year="";
   
                        $sql = false;
                        for ($j = 1; $j <= $data->sheets[0]['numCols']; $j++)
                        {
                            if (isset($data->sheets[0]['cells'][$i][$j]) && $data->sheets[0]['cells'][$i][$j] == 'Age')
                            {
                                $flag = true;
                                $i++;
                            }
                            if (isset($flag))
                            {
                                if (isset($data->sheets[0]['cells'][$i][$j]) &&  $data->sheets[0]['cells'][$i][$j] != "")
                                {
                                    if ($j == 1)
                                    {   
                                        $age = $data->sheets[0]['cells'][$i][$j];
                                        $age = !empty($age) ? $age : null;
                                        $sql = true;
                                    }
                                    if ($j == 2)
                                    {
                                        $wins =  $data->sheets[0]['cells'][$i][$j];
                                        $wins = !empty($wins) ? $wins : null;
                                        $sql = true;
                                    }
                                    if ($j == 3)
                                    {
                                        $most =  $data->sheets[0]['cells'][$i][$j];
                                        $most = !empty($most) ? $most : null;
                                        $sql = true;
                                    }
       
                                    if ($j == 4)
                                    {
                                        $year =  $data->sheets[0]['cells'][$i][$j];
                                        $year = !empty($year) ? $year : null;
                                        $sql = true;
                                    }
       
       
                                }
                            }//end flag if
                        }//end j if
                                if (isset($sql))
                                {
                                    $sSql = 'insert into group_age_tbl ( age, wins, most, year, group_id) values("'. $age . '","'.$wins.'","'. $most . '","'.$year.'","'.$group_id.'")';
                                            $res=execute($sSql);
                                            $inserted=mysql_insert_id();       
                                            $arrayid[] = $inserted;
                                }//end if of SQL
                        }
                }//end move_uploaded_file
             if($arrayid != "")
                $count=count($arrayid);
            else
                $count=0;
       } //end $ext == '.xls'
}//$excelFileName

$file=$_FILES['img_upload']['name'];
$path=$localpath ."uploadexcelfiles/". $file;
if(file_exists($path))
{
    unlink($path);
}
header("location:destination.php");
exit();



Friday, 22 March 2013

css


HIDDEN SCROLL IN BORWSER

ADD ON TOP THE CSS FILE

html { overflow-x:hidden;}

How to Add Multi-language Support to a PHP Website


For Download open in new tab

http://www.bitrepository.com/php-how-to-add-multi-language-support-to-a-website.html

Generate Csv file using PHP


<?php
ob_start();
session_start();
include('config.php');

// output headers so that the file is downloaded rather than displayed
header('Content-Type: text/csv; charset=utf-8');
header('Content-Disposition: attachment; filename=filename.csv');

// create a file pointer connected to the output stream
$output = fopen('php://output', 'w');

// output the column headings
//fputcsv($output, array('Subscribed User '));
fputcsv($output, array('Field1', 'Field2 ', Field3 '));

$rows = mysql_query("SELECT   Field1, Field 2, Field 3  FROM table ");

// loop over the rows, outputting them
while ($row = mysql_fetch_assoc($rows)) fputcsv($output, $row);

?>

PHP Basics: Accessing Remote URLs using cURL


http://tournasdimitrios1.wordpress.com/2010/10/17/php-basics-accessing-remote-urls-using-curl/

Hide Print Button While Printing A Page


<style type="text/css">

@media print {

.printer {

display: none;

}

}

</style>



<a href="javascript:window.print()" class="printer" ><img src="images/printer.jpeg" height="30" width="30" alt="Print" /></a>