Tuesday, 24 March 2015

AP'S



More than a decade after its introduction, REST has become one of the most important technologies for Web applications. Its importance is likely to continue growing quickly as all technologies move towards an API orientation. Every major development language now includes frameworks for building RESTful Web services. As such, it is important for Web developers and architects to have a clear understanding of REST and RESTful services. This tutorial explains REST architecturally, then dives into the details of using it for common API-based tasks.
While REST stands for Representational State Transfer, which is an architectural style for networked hypermedia applications, it is primarily used to build Web services that are lightweight, maintainable, and scalable. A service based on REST is called a RESTful service. REST is not dependent on any protocol, but almost every RESTful service uses HTTP as its underlying protocol. In this article, I examine the creation of RESTful services with HTTP.

Test Your API Online : https://apigee.com/console/linkedin

Wednesday, 11 March 2015

ZendFramework Tricks

 

Get module name in Zend Framework , bootstrap.php

 
$module = $this->getRequest()->getModuleName();
$this->url(array('module'=>$module,'controller'=>'index','action'=>'index'),'default',true) ;

Tuesday, 26 November 2013

PHP logic and Keywords

html_entity_decode,
Used to decode html ot its original View

  • http://www.infotuts.com/easily-integrate-paypal-payment-gateway-php/
  • to get This
  • page/value/64
  • $MemberID = $this->getParam('value');

Removing Script tag from text area : use strip_tags
nl2br(strip_tags($_REQUEST['aboutme'])),

Saturday, 23 November 2013

Magento Tricks(Not for sale)

Getting Start with Magento

  • fabicon.ico in home directry
  • fabicon.ico in theme folder
  • logo.gif, logo_email.gif, logo_print.gif in theme/images folder (for best review 167x47 images)
  • Do the same theme in default also
  • fabicon.ico in admin default folder
  • logo-large.gif(302x124), logo.gif (225x43), login_logo.gif (28x91 and 91x28) in admin default/images folder
  • image.jpg (262x262), small_image.jpg (135x135), thumbnail.jpg (50x50) in \images\catalog\product\placeholder folder

For Newsletter Create duplicate of subscribe.phtml and Call anywhere

<?php echo $this->getLayout()->createBlock('newsletter/subscribe')->setTemplate('newsletter/subscribe-bottom.phtml')->toHtml(); ?>

Joomla Tricks(Not For sale)

Call static image and stylesheet

<a href="#"><img title="facebook" alt="facebook" src="<?php echo JURI::root();?>/templates/alokjha/images/facebook-32x32.png" /></a>
<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/css/template.css" type="text/css" />

Call page title

<?php $mydoc =& JFactory::getDocument();$mytitle = $mydoc->getTitle();echo $mytitle;
 ?>

Call search form

<form method="post" action="/joomla/index.php" role="search">
    <div class="search">
        <label for="mod-search-searchword">Search...</label><input type="text" onfocus="if (this.value=='Search...') this.value='';" onblur="if (this.value=='') this.value='Search...';" value="Search..." size="20" class="txt_field" maxlength="20" id="mod-search-searchword" name="searchword">    <input type="hidden" value="search" name="task">
    <input type="hidden" value="com_search" name="option">
    <input type="hidden" value="472" name="Itemid">
    </div>
</form>

 <div id="fontsize"></div>
                                        <h3 class="unseen"><?php echo JText::_('TPL_BEEZ2_SEARCH'); ?></h3>
                                        <jdoc:include type="modules" name="position-0" />

Call Home page

<?php JURI::root(); ?>

Call front page in joomla

<?php
$app = JFactory::getApplication();
$menu = $app->getMenu();
if ($menu->getActive() == $menu->getDefault()) {
   
        echo 'This is the front page';
}
?>

Is this Front page?

Basic code, as shown at Joomla help, is
<?php $menu = & JSite::getMenu();
if ($menu->getActive() == $menu->getDefault()) {
echo 'This is the front page';
} ?>

For multi-language sites

Show different content based on selected language
<?php
$app = JFactory::getApplication();
$menu = $app->getMenu();
if ($menu->getActive() == $menu->getDefault( 'en-GB' )) {
echo 'This is the front page';
}
elseif ($menu->getActive() == $menu->getDefault( 'fr-FR' )) {
echo 'Il sagit de la premi?re page';
}
?>

<?php $menu = & JSite::getMenu();
if ($menu->getActive() == $menu->getDefault()) {
$frontpage="yes";
} ?>

to beginning of template’s index.php file

Every time, you want to check if user is on frontpage, use
<?php if ($frontpage) {//do something} ?>

Show text on
<?php if ($frontpage) {echo This is frontpage} ?>

Show module
<?php if ($frontpage) {echo '<jdoc:include type="modules" name="modulename" style="xhtml"/>';} ?>

Hide module
<?php if (!$frontpage) {echo '<jdoc:include type="modules" name="modulename" style="xhtml"/>'} ?>

only difference from previous example is little exclamation mark in if statement

Show long HTML code
<?php if ($frontpage): ?>
<div id="box1"><div>Content</div></div>
<div><div>Content </div></div>
<div id="box2">There can be anything</div>
<?php  endif; ?>

Add CSS class
<body<?php if (JRequest::getCmd('view') == frontpage)  {echo 'class="classname" '} ?>

Then of course define body.classname {} in your CSS file
Include Javascript
Paste this between head tags
<?php if ($frontpage") {echo '<script type="text/javascript" src="pathtoscripts/jquery.js"></script>';} ?>

joomla-banners

http://www.siteground.com/tutorials/joomla/joomla-banners.htm

Open Menu in title

<div id="Modulecontainer"> </div>
<p class="button btn-success"><strong><a class="modal" href="login-form" rel="{handler: 'iframe', size: {x: 640, y: 480}}">Login / </a> <a class="modal" href="registration-form" rel="{handler: 'iframe', size: {x: 640, y: 910}}">Registration</a></strong></p>

Sunday, 3 November 2013

WordPress Tricks (Not For Sale)

Creating new page template

Get Wordpress links

WordPress Directories:
home_url() Home URL http://www.example.com
site_url() Site directory URL http://www.example.com or http://www.example.com/wordpress
admin_url() Admin directory URL http://www.example.com/wp-admin
includes_url() Includes directory URL http://www.example.com/wp-includes
content_url() Content directory URL http://www.example.com/wp-content
plugins_url() Plugins directory URL http://www.example.com/wp-content/plugins
theme_url() Themes directory URL (#18302) http://www.example.com/wp-content/themes
wp_upload_dir() Upload directory URL (returns an array) http://www.example.com/wp-content/uploads

Creating More Menu

https://codex.wordpress.org/Navigation_Menus

Navigation Menus

. WordPress includes an easy to use mechanism for introducing customised navigation menus into a theme. In order to incorporate menu support into your theme, you need to add a few code segments to your theme files.

Function Reference

Register Navigation Menu
Show Navigation Menu

Register Menus

Firstly, in your theme's functions.php, you need to write a function to register the names of your menus. (This is how they will appear in the Appearance -> Menus admin screen.) As an example, this menu would appear in the "Theme Locations" box as "Header Menu".

function register_my_menu() {  
register_nav_menu('header-menu',__( 'Header Menu' )); }
add_action( 'init', 'register_my_menu' );

And this would make two menu options appear, header menu and extra menu -

function register_my_menus() {   
register_nav_menus( array(
'header-menu' => __( 'Header Menu' ),
'extra-menu' => __( 'Extra Menu' ) ) ); }
add_action( 'init', 'register_my_menus' );

Get specific Pages

https://codex.wordpress.org/Function_Reference/is_front_page

<?php is_front_page(); ?>

<?php if(is_front_page() || is_home() ) { ?>
<?php } ?>

Contact 7 page redirect url

put the code in
on_sent_ok: "location.replace('http://errorfound.in/significance/?page_id=9');"

Nivo slider Defect

    Warning : The permissions to the directory /home/username/sitename//wp-content/uploads/nivoslider4wp_files/ are invalid. Set them to 777 to be able to upload files.

First, the path is wrong on line 7 of file nivoslider4wp-panel.php. I changed it from:
$ns4wp_filesdir = ABSPATH.'/wp-content/uploads/nivoslider4wp_files/';
to:
$ns4wp_filesdir = ABSPATH.'wp-content/uploads/nivoslider4wp_files/';

Second, line 274 requires permissions 777 on the folder which is a MAJOR security issue. I changed it from:
<?php if (substr(decoct(fileperms($ns4wp_filesdir)),2) != '777') : ?>
to:
<?php if (substr(decoct(fileperms($ns4wp_filesdir)),2) < '755') : ?>

In my opinion these things need to be changed in the plugin core.

Create Dynamic Sidebar

Paste this code where you want to show..
  <?php // if ( dynamic_sidebar('sidebar-3') ) : else : endif; ?>
Paste this code in function.php
register_sidebar( array(
        'name'          => __( 'Secondary Widget Area', 'twentythirteen' ),
        'id'            => 'sidebar-2',
        'description'   => __( 'Appears on posts and pages in the sidebar.', 'twentythirteen' ),
        'before_widget' => '<aside id="%1$s" class="widget %2$s">',
        'after_widget'  => '</aside>',
        'before_title'  => '<h3 class="widget-title">',
        'after_title'   => '</h3>',
    ) );

Theme My Admin

FOR LOGIN PAGE
[theme-my-login default_action=login login_template=tml-login-form.php]

FOR REGISTER PAGE
[theme-my-login show_title=0 default_action=register register_template=tml-register-form.php]

FOR LOST PASSWORD PAGE
[theme-my-login show_title=0 default_action=lostpassword lostpassword_template=tml-lostpassword-form.php]

But now I'm not able to replicate this strategy for the profile page.
I've created a WP page for the themed profile and I've putted this shortcode in it's content:

[theme-my-login default_action=profile profile_template=tml-profile-form.php]

Woo Commerce Shortcode

    [woocommerce_cart] – shows the cart page
    [woocommerce_checkout] – shows the checkout page
    [woocommerce_pay] – shows the checkout pay page
    [woocommerce_thankyou] – shows the order received page
    [woocommerce_order_tracking] – shows the order tracking form
    [woocommerce_my_account] – shows the user account page
    [woocommerce_edit_address] – shows the user account edit address page
    [woocommerce_view_order] – shows the user account view order page
    [woocommerce_change_password] – shows the change password page
    [woocommerce_lost_password] – shows the lost password page
    [woocommerce_logout] – shows the logout page

open link in a new window

click on Screen Options (top right), and check the box labelled Link Target under the Show advanced menu properties heading.
Now select the appropriate target for your custom link.