Total Pageviews

Thursday, October 11, 2012

Magento DataBase configuration file


Magento DataBase configuration file location for simple changes, you find that information into the file:
/app/etc/local.xml
<default_setup>
                <connection>
                    <host><![CDATA[localhost]]></host>
                    <username><![CDATA[root]]></username>
                    <password><![CDATA[]]></password>
                    <dbname><![CDATA[magento]]></dbname>
                    <initStatements><![CDATA[SET NAMES utf8]]></initStatements>
                    <model><![CDATA[mysql4]]></model>
                    <type><![CDATA[pdo_mysql]]></type>
                    <pdoType><![CDATA[]]></pdoType>
                    <active>1</active>
                </connection>
            </default_setup>

Tuesday, July 3, 2012

Get Blog Notes: Facebook share button on your website:

<script>function fbs_click() {u=location.href;t=document.title;window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');return false;}</script><a href="http://www.facebook.com/share.php?u=<url>" onclick="return fbs_click()" target="_blank"><img src="/images/facebook.png" alt="Share on Facebook" /></a>

Tuesday, May 15, 2012

Active the corresponding link in navigation menu by scrolling the content.


<script type="text/javascript">
//<![CDATA[

  $(function() {


      $(window).scroll(function() {
          var threshold = $(window).height() / 4;

          var active_section;
          var active_section_top = -Infinity;

          $(".scrolling-document-section").each(function(index, section) {
              var section_top = $(section).offset().top - $(window).scrollTop();
              if (section_top > active_section_top && section_top < threshold) {
                  active_section_top = section_top;
                  active_section = section;
              }
          });

          if (active_section) {
              $("#menu-explore-features a").removeClass("active");
              $("#menu-explore-features a[href$='#" + $(active_section).attr("id") + "']").addClass("active");
          }
      });

      $(window).scroll();
  });

//]]>
</script>

Wednesday, April 11, 2012

How to grab tweets from Twitter using php

$tweets = 
json_decode(file_get_contents 
('http://twitter.com/statuses/user_timeline.json?
screen_name=USERNAME&count=10'));

var_dump
($tweets);
 
 
//json_decode(file_get_contents()) function 

How to add buttons to your website to help your visitors share content and connect with you on Twitter?

https://twitter.com/about/resources/buttons#follow


Add buttons to your website to help your visitors share content and connect with you on Twitter.

Monday, March 12, 2012

Magento How to add a static CMS block to the side bar


In Magento Go to
CMS > Static Blocks.
Create a new block

Open app/design/frontend/xxxxxx/xxxxxx/layout/catalog.xml
Add your static block to the left or right section in

<!-- Mage_Catalog -->

For example to add to the left sidebar..
<reference name="left">
<block type="cms/block" name="Block Title" >
<action method="setBlockId"><block_id>Identifier</block_id></action>
</block>
</reference>


OR

Open the file app/design/frontend/default/[your-theme]/template/page/Xcolumns-left.phtml by your favorite text editor
Find the line of code
<?php echo $this->getChildHtml('left') ?>
Add the following code line
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId(' Identifier ')->toHtml() ?>

Wednesday, February 22, 2012

Displaying the Preview image of Nextgen Gallery Using a Custom Select Query

You have to choose from an image of your gallery. If you don't want use one of them you can add a new image to the gallery, then click on Gallery settings (Click here for more settings) under the field Preview image  choose image from the drop down list!

Paste the bellow code in the template page, where you what to display the preview image of gallery. Don't forgot to change the gallery id.

<?php
$querystr = "SELECT wp_ngg_pictures.*, wp_ngg_gallery.* FROM wp_ngg_pictures, wp_ngg_gallery WHERE wp_ngg_pictures.pid = wp_ngg_gallery.previewpic AND wp_ngg_pictures.galleryid=5 ORDER BY wp_ngg_pictures.pid DESC
";

$pageposts = $wpdb->get_results($querystr, OBJECT);
$name=$pageposts[0]->filename;
$path=get_bloginfo('siteurl')."/".$pageposts[0]->path."/".$pageposts[0]->filename;
echo "<img src='".$path."' title='".$name."' width='100' height='75'/>";

?>

Monday, February 20, 2012

WordPress how to get the total count of posts from specific category


A custom function which will return total post counts from the specified category and its child categories.
function wp_get_cat_postcount($id) {
    $cat = get_category($id);
    $count = (int) $cat->count;
    $taxonomy = 'category';
    $args = array(
      'child_of' => $id,
    );
    $tax_terms = get_terms($taxonomy,$args);
    foreach ($tax_terms as $tax_term) {
        $count +=$tax_term->count;
    }
    return $count;
}

Friday, February 10, 2012

How to display the list of child pages on the parent page.

Displays a list of WordPress pages as links. It is often used to customize the sidebar or header.

We can display the list of child pages on the parent page.

Displays the sub-pages of a single Page only;
uses the ID for a Page as the value.

if($post->post_parent)
{
$parent_title = get_the_title($post->post_parent);
echo "<h3 class='product1-title'>".$parent_title.":</h3>";
$children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0");
}
else
{
$parent_title = get_the_title($post->post_parent);
echo "<h3 class='product1-title'>".$parent_title.":</h3>";
$children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");
}
if ($children) { ?>
<ul id="subnav">
<?php echo $children; ?>
</ul>
<?php }?>

Saturday, February 4, 2012

Display custom wordpress gallery images from post attachment

How to display custom wordpress gallery images from post attachment

The [gallery] shortcode is used in a Post or Page to display a thumbnail gallery of images attached to that post. Or You can use like this: 

<table cellspacing="0" cellpadding="5" align="left">
    <tbody>
    <tr>
   
    <?php
    $images = get_children( array('post_parent' => $post->ID, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID') );
    if ($images) {
    $size = 'thumbnail';
    $num_of_images = count($images);
        foreach ($images as $image) {
        $img_title = $image->post_title;   // title.
        $img_description = $image->post_content; // description.
        $img_caption = $image->post_excerpt; // caption.
        $img_url = wp_get_attachment_url($image->ID); // url of the full size image.
        $preview_array = image_downsize( $image->ID, $size );
        $img_preview = $preview_array[0]; // thumbnail or medium image to use for preview.
        ?>
    <td valign="top">
<a class="lightwindow" href="<?php echo $img_url; ?>" rel="example1"><img class="alignleft size-full wp-image-911" title="<?php echo $img_title; ?>" src="<?php echo $img_preview; ?>" alt="<?php echo $img_caption; ?>" width="100" height="100" /></a>
        </td>
        <?php
        }
    }?>
   
</tr>
</tbody>
</table>

Friday, February 3, 2012

WordPress Administration menu example


Here is a very simple example of the three steps just described. This plugin will add a sub-level menu item under the Settings top-level menu, and when selected, that menu item will cause a very basic screen to display

In this example, the function, my_plugin_menu(), adds a new item to the Administration menu via the add_options_page function.
<?php
add_action('admin_menu', 'my_plugin_menu');

function my_plugin_menu() {
add_options_page('My Plugin Options', 'My Plugin', 'manage_options', 'my-unique-identifier', 'my_plugin_options');
}

function my_plugin_options() {
if (!current_user_can('manage_options'))  {
wp_die( __('You do not have sufficient permissions to access this page.') );
}
echo '<div class="wrap">';
echo '<p>Here is where the form would go if I actually had options.</p>';
echo '</div>';
}
?>

How to add administration menus in wordpress


This article explains how plugin authors can add administration menus.

Using Wrapper Functions

Since most sub-level menus belong under the Settings, Tools, or Appearance menus, WordPress supplies wrapper functions that make adding a sub-level menu items to those top-level menus easier. Note that the function names may not match the names seen in the admin UI as they have changed over time:

Dashboard
<?php add_dashboard_page( $page_title, $menu_title, $capability, $menu_slug, $function); ?>


Posts
<?php add_posts_page( $page_title, $menu_title, $capability, $menu_slug, $function); ?>


Media
<?php add_media_page( $page_title, $menu_title, $capability, $menu_slug, $function); ?>


Links
<?php add_links_page( $page_title, $menu_title, $capability, $menu_slug, $function); ?>


Pages
<?php add_pages_page( $page_title, $menu_title, $capability, $menu_slug, $function); ?>


Comments
<?php add_comments_page( $page_title, $menu_title, $capability, $menu_slug, $function); ?>


Appearance
<?php add_theme_page( $page_title, $menu_title, $capability, $menu_slug, $function); ?>


Plugins
<?php add_plugins_page( $page_title, $menu_title, $capability, $menu_slug, $function); ?>


Users
<?php add_users_page( $page_title, $menu_title, $capability, $menu_slug, $function); ?>


Tools
<?php add_management_page( $page_title, $menu_title, $capability, $menu_slug, $function); ?>


Settings
<?php add_options_page( $page_title, $menu_title, $capability, $menu_slug, $function); ?>

More:Here is an example of a WordPress plugin that inserts new menus into various places:
 Administration_Menus

Tuesday, January 31, 2012

Category Posts

<?php
/*
Template Name: Category Posts
*/
get_header();
?>

        <div id="content-container">
            <div id="content" role="main">
<?php
//get all terms (e.g. categories or post tags), then display all posts in each term
$taxonomy = 'category';//  e.g. post_tag, category
$param_type = 'category__in'; //  e.g. tag__in, category__in
$term_args=array(
 'orderby' => 'name',
 'order' => 'ASC'
);
$terms = get_terms($taxonomy,$term_args);
if ($terms) {
 foreach( $terms as $term ) {
   $args=array(
     "$param_type" => array($term->term_id),
     'post_type' => 'post',
     'post_status' => 'publish',
     'posts_per_page' => -1,
     'caller_get_posts'=> 1
     );
   $my_query = null;
   $my_query = new WP_Query($args);
   if( $my_query->have_posts() ) {
     echo '<h2>List of Posts in '.$taxonomy .' '.$term->name.'</h2>';
     while ($my_query->have_posts()) : $my_query->the_post(); ?>
     <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
                    <?php if ( is_front_page() ) { ?>
                        <h2 class="entry-title"><?php the_title(); ?></h2>
                    <?php } else { ?>
                        <h1 class="entry-title"><?php the_title(); ?></h1>
                    <?php } ?>

                    <div class="entry-content">
                        <?php //the_content();
                        the_excerpt();
                        the_post_thumbnail(); ?>
                    </div><!-- .entry-content -->
                </div>
      
<?php

           endwhile;
   }
 }
}
wp_reset_query();  // Restore global post data stomped by the_post().
?>

            </div><!-- #content -->
        </div><!-- #content-container -->

<?php get_sidebar(); ?>
<?php get_footer(); ?>

Friday, January 27, 2012

Category Posts Widget

Adds a widget that shows the most recent posts in a single category.

Category Posts Widget is a light widget designed to do one thing and do it well: display the most recent posts from a certain category.

Category Posts Widget

Tuesday, January 24, 2012

PHP array functions

PHP array  samples
 1) Desplaing the array in order, with out using sort functions
<?php
$array=array(1,20,5,16,7,19,3);
$cnt = count($array) - 1;
$FinalTemp = array();
for ($i = 0; $i <= $cnt; $i++) {
foreach($array as $key=>$value)
{
     if($value==max($array))
 {
  $sort[] = max($array);
  unset($array[$key]);
  }
}
}
 print_r($sort);
?>

2) In the main array, First delete one array values and then add other array values to the main array.
<?php
$array=array(5,4,5,7,3,6,4,1,8,4,5,6,2,1);
$delete=array(4,5,6);
$add=array(11,12,12,18);

foreach($array as $k=>$val)
{
if(in_array($val, $delete))
{
unset($array[$k]);
}
}
$result = array_merge((array)$array, (array)$add);
arsort($result);
print_r($result);
?>


3) array_count_values — Counts all the values of an array

<?php
$arr=array(a,c,k,n,n,h,r,a,a,a,c,h,b,h,k,n);
print_r(array_count_values($arr));
?>

Back to Top Scroll Up

The following Javascript will go to top of the page, when the link is clicked.
// JavaScript Document

var up_timer

function getPosition(){
yoko = document.body.scrollLeft || document.documentElement.scrollLeft;
tate = document.body.scrollTop  || document.documentElement.scrollTop;

}

function pageup(x,y){
if(up_timer) clearTimeout(up_timer);
if(y >= 1){
getPosition();
var divisionY = (tate-(tate/5));
var Y = Math.floor(divisionY);
window.scrollTo(yoko,Y);
up_timer = setTimeout("pageup("+yoko+","+Y+")",2);
}else{
window.scrollTo(yoko,0);
clearTimeout(up_timer);
}
}

function scrollup(){
getPosition();
pageup(yoko,tate)
}

Saturday, January 21, 2012

Simple rewriting using .htaccess


All requests to whatever.htm will be sent to whatever.php:

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*)\.htm$ $1.php [NC]

The [NC] part at the end means "No Case", or "Case-Insensitive".
Requests to the .html automatically rewrite to .php. 
Ex: If it is whatever.htm or whatever.php, but they always get whatever.php in the browser, and this works even if whatever.htm doesn't exist!

Sunday, January 15, 2012

BLOG SPOT GET BLOG NOTES HTML WORDPRESS PHP DRUPAL CODEIGNITER

BLOG SPOT GET BLOG NOTES  HTML WORDPRESS  PHP DRUPAL CODEIGNITER
get-blognotes: Useful Coding Tools HTML,  PHP, WordPress, Drupal, Codeigniter, and JavaScript Libraries For Web Developers .
  http://get-blognotes.blogspot.in/


CodeIgniter

 CodeIgniter Server Requirements

  • PHP version 5.1.6 or newer.
  • A Database is required for most web application programming. Current supported databases are MySQL (4.1+), MySQLi, MS SQL, Postgres, Oracle, SQLite, and ODBC.
CodeIgniter Installation Instructions

  • Unzip the package
  • Upload the CodeIgniter folders and files to your server. Normally the index.php file will be at your root.
  • Open the application/config/config.php file with a text editor and set your base URL. If you intend to use encryption or sessions, set your encryption key. 
  • Open the application/config/database.php file with a text editor and set your database settings. 
How to enable arbitrary URL parameters on CodeIgniter

Google adwords isn't being recognized within google analytics, Because by default CodeIgniter will not support parameters in url.
 
Need changes in you config file like below.
$_SERVER['PATH_INFO'] = $_SERVER['ORIG_PATH_INFO'];

$config['uri_protocol'] = 'PATH_INFO';

Wednesday, January 11, 2012

How to create a built-in contact form for your WordPress theme


Many WordPress plugins can add a contact form to your blog, but a plugin is not necessary.
In this tutorial, I’m going to show you how you can create a built-in contact form for your WordPress theme.

How to create a built-in contact form for your WordPress theme

PHP MYSQL before date descending order and after date ascending orderr

PHP MYSQL before date descending order and after date ascending order
(
SELECT *
FROM `usersexample`
WHERE date_col<=current_date
ORDER BY
date_col DESC
)
UNION (


SELECT *
FROM `usersexample`
WHERE date_col >=current_date
ORDER BY date_col ASC
)