tagging system with chosen plugin and codeigniter.
If you worked before with some popular content management systems like WordPress or Joomla or Drupal you may notice there all always has tagging systems, the name changed from CMS to another but the concept is one, Are you remember my advice?
So what is the concept behind tagging systems, and what is the different between tags and categories?
Difference between Categories and Tags:
- They are meant for a broad grouping of your posts. Think of these as general topics or the table of contents for your site. Categories are there to help identify what your blog is really about. It is to assist readers finding the right type of content on your site. Categories are hierarchical, so you can sub-categories.
- They are used to group your posts, they are the topics which help your visitors to identify your post, and whether it is the post they are looking for?
- You should not have a ton of categories on your blog because categories are meant to be broad topics or sections in your blog
- They are hierarchical and you can also make subcategories make your posts more systematic as shown in the image below.
- Tags are more specific details within a category. They are not hierarchical, tags are those keywords that are self-descriptive to explain your content.
- As an example, if your post is been categorized into “animal” category then your tags can be a dog, cat etc.
-You can assign multiple tags to a single post, it will help you to improve the usability of your site, but remember to only use those tags which can be justified with your post.
- In very short I say tags come in where your categories are out enough to describe the type of content in an explanatory way.
So, this is the difference between tags and categories, now you will learn practically how to build dynamic tagging system by using chosen jQuery plugin and Codeigniter PHP framework, let’s go.
Client want to Connecting countries to services, if visitors want to visit Egypt then they can see what services related to Egypt like swimming or camping or see pyramids
1- First step : build SQL schema, we suppose there are three tables (Country,Service,Country_service),one to save countries, another to save services and the last to save relations between countries and their services ,take a look at this diagram :
2- Second step: create country controller to create and edit countries with its services
3- Third step: create country model which deal with database tables
4- Fourth step : download chosen jQuery plugin from here and put it in assets directory
5- Fifth step: create two files in views directory, one to add country another to edit country and you will include chosen links that point to your assets directory.
And it’s done, you can download Full code from here