Sidebar plays a very important role in the blog website. We are extending "how to create a blog from beginning in PHP " in details. This is the third part of the blog CMS. In this tutorial, we will learn create a sidebar on a blog website. In the sidebar, we can display recent posts, categories, and tags.
CSS stylesheet is used to create a sidebar.We had create sidebar stylesheen in the first tutorial of the blog CMS. Here we will create sidebar for both admin and blog. Let's create a sidebar in public blog pages.
Create a file sidebar.php in the blog folder –
In the code above . we created a demo list of blog recent post, categories and tags. We will add these thinks in later tutorials.
The sidebar file is ready.
Now, include the sidebar file in the index and show.php file of the blog folder.
Open the index file and add the line above the footer file (at line 50, inside the container div block)
Check the code below –
<?php //sidebar content //added sidebar
<?php //footer content //already added
In the code above, we added the sidebar file using include() function inside the container div block.
Now, open the show.php file and include the sidebar.php file inside the container div block.
<?php //sidebar content
Now , add the sidebar for admin panel.
Let’s create another sidebar file inside the admin folder and use the code below.
Let’s understand the code above.
We have added some links to the sidebar code for a quick shortcut. We created a count code for blog post counter that counts all posts and display the number of posts in the sidebar from the techno_blog table.
Now, include the sidebar.php file in –
Include the sidebar.php file above the footer.php file.
<?php //add above the footer
<?php //already added
Some links in the admin’s sidebar give the page not found because the pages for these links will be created in the next tutorials. Kindly, do not remove any link. These will be used in the next tutorials.
Complete Blog CMS system in PHP with MYSQL database | PHP scripts
Payment form using PayUmoney payment Gateway in PHP | Source Scripts
Dynamic Countdown timer using JS ,PHP and MYSQL | Animated timer
Payment form by PayUmoney gateway with GST invoice,email | PHP software