Category Archives: Misc

Strategy for API using Codeigniter REST!

What was needed?

An existing codeigniter application needed to be fixed, and API endpoints needed to be created for a mobile application.  

How we tackled it?

We implemented REST CodeIgniter API using the RESTful library by CHRIS.  The controllers worked flawlessly out of the box but there was also a requirement for a standalone controller to take care of certain data-exchange, and REST was not an option. A controller was coded to accept the post data, process it and returned the desired result in JSON format. All tests using postman and via jQuery.ajax turned out successful until tests were done from the mobile application itself. Apparently, the mobile application was not sending form-data or x-www-form-urlencoded data. The application was sending JSON data with application/json header which PHP was unable to read using the $_POST or $this->input->post() class of CodeIgniter.

Read more

Check WordPress Admin-Bar functionality

if( jQuery(‘#wpadminbar’).length ){ jQuery(‘select-your-fixed-bars’).css(‘padding-top’,’31px’); } // 31px( > M) and 46px (S)

WordPress | Items of Custom Post Type

<?php /** * Template Name: Page of Products * * Selectable from a dropdown menu on the edit page screen. */ ?> <?php get_header(); ?> <div id=”container”> <div id=”content”> <?php $type = ‘products’; $args=array( ‘post_type’ => $type, ‘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() ) { while ($my_query->have_posts()) : $my_query->the_post(); ?> <p><a href=”<?php the_permalink() ?>” rel=”bookmark” title=”Permanent Link to <?php the_title_attribute(); ?>”><?php the_title(); ?></a></p> <?php endwhile; } wp_reset_query(); // Restore global post data stomped by the_post(). ?> </div><!– #content –> </div><!– #container –> <?php get_sidebar(); ?> <?php get_footer(); ?>

What to do if cPanel CSS and layout goes wonky – check cloudflare first!

On my cloudflare activated domain, the cPanel was appearing in a styleless and imageless manner. On searching for a cause for the same, I ended up going through a number of search results and finally found one which seemed to address my issues. Cloudflare was caching up the CSS for the cPanel in addition to the rest of the domain and hence needed to be bypassed for the cPanel. And then everything was fixed. This error is mentioned by them in their docs, but it doesn’t show up in google results untill unless “cloudlfare” and “cPanel” are searched together. Cloudflare docs –

Read more