Using Controller in Laravel

Hello Friends
How are you? Hope you are fine in health. Let’s go to start the work with Laravel Controller. Its a funny work. Let’s go to start funny journey…

In MVC (Model-View-Controller) patter, controller is the heart of them. All of the logical code of your site will be place in controller section. You have to extends your controller based on your base controller. Let’s go…

In our laravel directory go to application/controllers/ and create a new file called users.php. Now wrtie the below code…

<?php

class User_Controller extends Base_Controller{

public function action_index(){

echo “This is Our Index Page”;

}

public function action_login(){

echo “This is our Login Page”;

}

}

?>

Continue reading

Advertisements

How to add Another Sidebar in WordPress Blog?

Tuts Type : WordPress Coding
Level : Beginnear / Intermediate
Time : 10-15 Minitues

 

Most of the time, we use the wordpress readymate theme. That kind of theme are opensource that’s why we are using this. But, unfortunately in this case, we face some porblem. Most of the time, we get only 1 sidebar in admin panel. Sometimes we need add more in side bar but limitation of sidebar, we can not do this. Today I am going to teach how to add more side bar in your wp theme.

First of all, please download any free wp theme. After downloading the theme, install the theme as usally. Now, go to your directory where you have install the theme. For your kind infromation I am using Windows and Xampp. Normally it will store in you directory [Your dirve name]:/xampp/htdocs/wp/wp-content/theme/[your-new-theme-name].
Go to this theme and find out the functions.php file. Normally a file called functions.php are available in your directory. If not available, just open the notepad and create a new file called functions.php. Now write the following core in this file and save this.

<?php

if ( function_exists(‘register_sidebars’) ){

register_sidebars(1);

}

?>

Continue reading

Journey with Laravel : A young PHP Framework for Next Generation

Tutorial Details
Name : Laravel – PHP Framework
Type : PHP Framewrok
Language : PHP
Level : Beginner
Estimated Time : 40 Minuets
Comments : Next generation PHP Framework

Hello,
Today I am going to introduce a new PHP Framework called Laravel. It’s a young PHP framework. Before starting this tuts, lets go to know why you have to learn framework?

Yes, definitely, there is so much PHP framework (like zend, cake, codeigintor, yii etc.) available. But why need new framework? There are some difference between conventional framework and LARAVEL.

WHY YOU LEARN?
1. Very Light framework
2. Powerful and Flexible
3. Elegance and Simplicity
4. Programming (i.e. framework) doesn’t have painful
5. Well decorated Documents.
6. No need to configure
7. CURD & PHP template system support
8. Migration System
9. and more…
Continue reading

Set Cron Job in Cpanel by PHP


Tutorial Details
Subject : PHP
Duration : 15 Minuts
Level : Medium / Advanced level PHP Programmer
Language : Html & PHP


 

Hello Friends,
Lets go to learn how to set a cron job in cpanel by using PHP script. We are ready to write a simple PHP script for sending email to an email address in every 5 minutes by using creating cron job. First of all, we have to write a PHP email script. I am sending the code in below-

<?php

$to = ‘abc@abc.com’;
$sub = ‘Hello Cron Job!’;
$message = ‘This is for dummy Cron Job.’;
$from = “someonelse@example.com”;
$headers = “From:” . $from;

mail($to, $sub, $message, $headers);

?>

After writing this, I am saving this file named email.php. Now, lets go to our Cpanel. After then, go to public_html and create a new folder test.

Step 1: After successfully loing your Cpanel….

Step 2 : In Advanced tab, you will get the icon entitled Cron jobs. Click on this icon.

Step 3: In Add New Cron, fill up the form. First of all, choose a Common Settings. You can choose anything. Others fields, you can change or may not.

Step 4: Now go to the last field Command and write php /home/user_name123/public_html/test/cron.php for PHP. [In user_name123, you have to use cpanel user name]

Step 5: Now click Add a New Cron Job button.

Ok, you have completed all the work. Now, wait and see. Your script will be work according to your cron time.

Thanks for ready. Take Care. Bye

WP Pagination Code

Hello Friends,
Lets go to learn WP Pagination code.
Suppose, we want to show the latest article post into our blog by last 5. The code are in below-

<h3>Recent Articles</h3>

<?php

$temp = $wp_query;
$wp_query= null;
$wp_query = new WP_Query();
$wp_query->query(‘showposts=5′.’&paged=’.$paged); ?>

<?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
     <a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a>
<?php endwhile; ?>

<div>
  <div><?php previous_posts_link('&laquo; Previous') ?></div>
  <div><?php next_posts_link('More &raquo;') ?></div>
</div>
<?php $wp_query = null; $wp_query = $temp;?>

This is the very simple code for showing the last 5 article post from my wp blog. Thanks fore reading this article.

 

Show Specific Post in WordPress Theme

Hello Friends, how are you?
Now I am going to tell how to show a specific post in specific page of wordpress theme. Suppose, I have a page entitled ‘page-forum.php’ and I want to show a specific post into this page. The code are below-

<?php

$post_id = 26;      //identify the no of the post
$queried_post = get_post($post_id);
$title = $queried_post->post_title;    //taking the page title specificly
echo $title;     //print out the page title
echo $queried_post->post_content;    //print out the content

?>

In this case, I use the 26 for post id. You can use any thing according to your post ID. Thanks for reading this post.

Take care, Bye bye