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>

pop Window

<script type="text/javascript">// 
function popitup(url) {
       newwindow=window.open(url,'name','scrollbars,height=500,width=500','scrollbars');
       if (window.focus) {newwindow.focus()}
       return false;
}
</script>

Twitter feed in php


<?php
$timeline="http://api.twitter.com/1/statuses/user_timeline.xml?screen_name=Your twitter username ";
$xml= new SimpleXMLElement(file_get_contents($timeline));
$i=0;
print "<ul class=\"tweet_list\">";
foreach($xml ->children() as $tstatus)
    {
        $stat=$tstatus->text;
        $split= preg_split('/\s/',$stat);
        print "<li class=\"tweet\"><p class=\"tweet_text\">";
        foreach ($split as $word)
            {

                if (preg_match('/^@/',$word)) {
                               print " "."<a href=http://www.twitter.com/".substr($word,1).">".$word."</a>";
                               }
                               else if (preg_match('/^http:\/\//',$word)){
                                     print " "."<a href=".$word.">".$word."</a>";
                               }
                               else
                                   {
                                   print " ".$word;
                               }

                              
            }
print "</p>";
print "<span class=\"date\">".substr($tstatus->created_at,0,strlen($tstatus->created_at)-14)."</span>";
print "</li>";
$i++;
if ($i==5)
    {
       
        break;
    }
    }
print "</ul>";
?>

Social sharing


Social sharing content


https://www.addthis.com/get/sharing
            or
<a class="addthis_button" href="http://addthis.com/bookmark.php?v=250&amp;pub=xa-4b052bb8729b6bf2"><img src="http://s7.addthis.com/static/btn/v2/lg-share-en.gif" width="125" height="16" alt="Bookmark and Share" style="border:0"/></a>
<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pub=xa-4b052bb8729b6bf2"></script>

Simple Way

 <iframe src="https://www.facebook.com/plugins/like.php?href=YOUR SITE URL"
        scrolling="no" frameborder="0"
        style="border:none; width:450px; height:80px"></iframe>

All Social Plugins

https://developers.facebook.com/docs/plugins/ 

OR

jQuery Floating Social Share Plugin: floatShare

http://www.egrappler.com/jquery-floating-social-share-plugin-floatshare/

Upload excel Sheet data in mysql using Php


Upload excel Sheet data in mysql using Php

Note:Must require_once 'excel_reader.php';

I have not added html code only php code ,


Below code for two fields ,No,Name

if(isset($_POST['submit']))
{

$excelFileName = $_FILES['img_upload']['name'];
$uploadDir = '../uploadexcelfiles/';
$rand=rand(0,9999);
$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;
for ($i = 1; $i <= $data->sheets[0]['numRows']; $i++)
{
$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] == 'No')
{
$flag = true;
$i++;
}
if (isset($flag))
{
if (isset($data->sheets[0]['cells'][$i][$j]) && $data->sheets[0]['cells'][$i][$j] != "")
{
if ($j == 1)
{
$No = $data->sheets[0]['cells'][$i][$j];
$No = !empty($No) ? $No : null;
$sql = true;
}
if ($j == 2)
{
$Name = $data->sheets[0]['cells'][$i][$j];
$Name = !empty($Name) ? $Name : null;
$sql = true;
}

}
}//end flag if
}//end j for

if (isset($sql))
{
// Apply sql query

}//end if of SQL
$No = "";
$Name="";

}

}
}

}

Chrismas countdown


Christmas Countdown

<p><embed src="http://www.satisfaction.com/christmas-countdown-generator/countdown1.swf?x=http://www.satisfaction.com" quality="high" bgcolor="#000000" width="450" height="200" name="countdown1" align="middle" allowScriptAccess="samedomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /><br><a href='http://www.satisfaction.com/christmas-countdown-generator/'>Christmas Countdown</a></p>

VISIT
http://www.satisfaction.com/christmas-countdown-generator/

HOW TO GET THE SPAN VALUE IN JQUERY


HOW TO GET THE SPAN VALUE FROM HREF TAG IN JQUERY

<a id='cmbpg_child' selected >
<span id='title '>Iliyas</span>
</a>

var href = $("#cmbpg_child .selected span").text();

:selected Selector


http://api.jquery.com/selected-selector/

Second Example

<select id="title">
  <option value="1">Mr</option>
  <option value="2">Mrs</option>
  <option value="3">Miss</option>
</select>
 
$("#title option:selected").text(); 

POST DATA USING JQUERY


jquery url >>http://code.google.com/p/jqueryjs/downloads/list

function POST()
{
var getvaluefrominput= $('#INPUTID').val();
    $.ajax({
        type: 'POST',
        url: 'phppagename.php',
        data: "ID="+getvaluefrominput,
        success: function(msg)
        {

           alert(msg)
          $('#ID').html(msg);
         }
    });
}
<?php
function curPageName() {
return substr($_SERVER["SCRIPT_NAME"],strrpos($_SERVER["SCRIPT_NAME"],"/")+1);
}
echo curPageName();

?>
Q=How to get the current file name
A=
<?php
$currentFile = $_SERVER["PHP_SELF"];
$parts = Explode('/', $currentFile);
echo $parts[count($parts) - 1];
?>

Q-Cuurent URL
<?php
function curPageURL() {
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
return $pageURL;
}
?>
<?php
echo curPageURL();
?>

Favicon ICon

Step To Create Favicon Icon.

Find This Text : Windows, सभी फ़ोटोशॉप संस्करणों (इस चुनें अगर आप बस वेब साइट favicon बनाना चाहते हैं)

Click On Window Link ,After Downloaded  Extract It .

Open Folder copy "ICOFormat.8bi" file and Past into

C:\Program Files\Adobe\Adobe Photoshop CS5\Plug-ins\File Formats 

After past restart photoshop (means close then reopen it).

your image size should be 16(width) and select 4th option from drop down



File save as .icon


Enjoy.................
Support For All Browser
THEN ADD THIS CODE IN PAGE(If have header page then add in it below code )
<link rel="shortcut icon" type="image/x-icon" href="http://www.abc.com/favicon.ico" />