Advertisement:

Author Topic: [TUTORIAL] How to add icons to categories in Bender theme via css  (Read 9234 times)

Zen Team

  • Jr. Member
  • **
  • Posts: 51
This is tutorial on how to add icons to bender theme with classes and css.

First step:

Go to your functions.php and locate this code:
Code: [Select]
<h1><a class="category<?php echo osc_category_slug() ; ?>" href="<?php echo osc_search_category_url() ; ?>"><?php echo osc_category_name() ; ?></a></h1>

We will need to add some classes to that code and change some things.
As you can see below code i have added class to <h1> and <a>. And i have changed slug to id. which we will need later.

Replace the above code with this below:
Code: [Select]
<h1 class="icon_c"><a class="category cat_<?php echo osc_category_id() ; ?>" href="<?php echo osc_search_category_url() ; ?>"><?php echo osc_category_name() ; ?></a></h1>

Now that done we will work with main.css.

First you will gather the id's for your main category titles. To do so you just go to your main home page and right click on the name and select "inspect element"

And you will see class like this "Class="category cat_(a number)"". Remeber that number and let's go to main.css.

Here we will add some styles:

To call the icon for the Computer version we will need this css line:


.icon_c .cat_27 {
   background:url(/img/house.png) no-repeat left !important;
   text-transform:uppercase;
   padding-left:24px;
}

As you can see i have used the icon_c class that i gave to <h1> and the cat_(a number) i gave to <a>. The number is something you should change to your own.

Now we need to add some css for the mobile version:


.active .cat_27{
   background: #228DAC url(/img/house_white.png) no-repeat left !important;
   text-transform:uppercase;
   padding-left:24px;
}

On the above code for mobile i have changed .icon_c to .active. Since we need to change icon when category is active. In this case to a white icon.

So you will need two photos (if you do like i did), which i have used. Since the background on mobile is blue when active (or black, depending of your theme color)

Upload the files to your server and you have icons next to your title. I have attached a image on how it looks on the computer and mobile.

To download icons easy go to this domain

http://www.iconsdb.com/

REMEMBER THAT THE CSS ABOVE IS FOR MY NEEDS, SO YOU CAN PLAY AND CHANGE WHAT YOU NEED FOR YOUR SITE. EVERYTHING IN RED SHOULD BE CHANGED BY YOU!

I have chosen padding 24px since my icons are 24x24 and aligned left


« Last Edit: July 16, 2014, 03:05:58 am by zenteam »

Salvat0re

  • Newbie
  • *
  • Posts: 40
Re: [TUTORIAL] How to add icons to categories in Bender theme via css
« Reply #1 on: August 01, 2014, 02:08:24 am »
Hi i try edit main.css, but with notepad++ is compacted . ¿How can i edit well?

Sample:

Quote
article,aside,details,figcaption,figure,footer,header,hgroup,nav,section{display:block}audio,canvas,video{display:inline-block;*display:inline;*zoom:1}audio:not([controls]){display:none}html{font-size:100%;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}a{color:#069}a:focus{outline:thin dotted #333;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}a:hover,a:active{outline:0}sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline}sup{top:-0.5em}sub{bottom:-0.25em}img{max-width:100%;width:auto\9;height:auto;vertical-align:middle;border:0;-ms-interpolation-mode:bicubic}#map_canvas img{max-width:none}button,input,select,textarea{margin:0;font-size:100%;vertical-align:middle}button,input{*overflow:visible;line-height:normal}button::-moz-focus-inner,input::-moz-focus-inner{padding:0;border:0}button,input[type="button"],input[type="reset"],input[type="submit"]{cursor:pointer;-webkit-appearance:button}input[type="search"]{-webkit-box-sizing:content-box;-moz-box-sizing:content-box;-ms-box-sizing:content-box;-o-box-sizing:content-box;box-sizing:content-box;-webkit-appearance:textfield}input[type="search"]::-webkit-search-decoration,input[type="search"]::-webkit-search-cancel-button{-webkit-appearance:none}textarea{overflow:auto;vertical-align:top}.has-placeholder{position:relative;display:block;float:left}.has-placeholder label{position:absolute;top:0;left:0;vertical-align:middle;color:#646464;line-height:43px;height:100%;width:100%;text-decoration:none;padding:0 15px;text-shadow:0 1px 0 #ffffff;overflow:hidden}textarea{background-color:#fff;border:solid 1px #bfbfbf;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-left-radius:3px;border-bottom-right-radius:3px;border-top-left-radius:3px;border-bottom-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;box-shadow:inset 0 1px 0 0 #E0E0E0;display:inline-block;vertical-align:middle;color:#646464;line-height:1em;text-decoration:none;padding:10px;box-shadow:inset 0 1px 0 0 #dfd8d8;width:280px}div.select-box-focus{outline:0;border:1px solid #5B9DD9;-webkit-box-shadow:0 0 5px 1px #5B9DD9;-moz-box-shadow:0 0 5px 1px #5B9DD9;box-shadow:0 0 5px 1px #5B9DD9}.select-box{z-index:0;position:relative;display:inline-block;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-left-radius:3px;border-bottom-right-radius:3px;border-top-left-radius:3px;border-bottom-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;width:auto;background-color:#f9f9f9;background-color:#f9f9f9;background-image:-webkit-gradient(linear, left top, left bottom, color-stop(0%, #f9f9f9),color-stop(100%, #e0dada));background-image:-webkit-linear-gradient(top, #f9f9f9,#e0dada);background-image:-moz-linear-gradient(top, #f9f9f9,#e0dada);background-image:-ms-linear-gradient(top, #f9f9f9,#e0dada);background-image:-o-linear-gradient(top, #f9f9f9,#e0dada);background-image:linear-gradient(top, #f9f9f9,#e0dada);border:solid 1px #d3d3d3;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-left-radius:3px;border-bottom-right-radius:3px;border-top-left-radius:3px;border-bottom-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;display:inline-block;vertical-align:middle;color:#fff !important;line-height:43px;text-decoration:none;padding:0 15px;box-shadow:inset 0 1px 0 0 #fff;text-shadow:0 1px 0 rgba(0,0,0,0.3);padding:0px;overflow:hidden}.select-box .select-box-label{height:16px;overflow:hidden;display:block;line-height:16px;float:left;position:absolute;top:0;color:#bababa;padding:0px 15px;height:100%;color:#646464;line-height:30px;text-shadow:0 1px 0 #ffffff}.select-box a:hover{text-decoration:none}.select-box select{position:relative;left:0px;top:0px;width:100%;height:30px;-webkit-appearance:none;z-index:1003;padding-right:45px}.select-box-icon{z-index:0;position:absolute;right:13px;top:-7px;right:0px;height:100%;width:24px;text-decoration:none;display:block;font-family:"icons";color:#404040;font-size:0.8em;text-align:left}.ui-button{background-color:false;background-color:#f0f0f0;background-image:-webkit-gradient(linear, left top, left bottom, color-stop(0%, #f0f0f0),color-stop(100%, #c9c9c9));background-image:-webkit-linear-gradient(top, #f0f0f0,#c9c9c9);background-image:-moz-linear-gradient(top, #f0f0f0,#c9c9c9);background-image:-ms-linear-gradient(top, #f0f0f0,#c9c9c9);background-image:-o-linear-gradient(top, #f0f0f0,#c9c9c9);background-image:linear-gradient(top, #f0f0f0,#c9c9c9);border:solid 1px #cacaca;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-left-radius:3px;border-bottom-right-radius:3px;border-top-left-radius:3px;border-bottom-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;display:inline-block;vertical-align:middle;color:#5f5f5f !important;line-height:43px;text-decoration:none;padding:0 15px;box-shadow:inset 0 1px 0 0 #fff;text-shadow:0 1px 0 rgba(255,255,255,0.3)}input.ui-button,button.ui-button{padding-left:10px;padding-right:10px}.ui-button-main{background-color:#35c3d9;background-color:#35c3d9;background-image:-webkit-gradient(linear, left top, left bottom, color-stop(0%, #35c3d9),color-stop(100%, #18a7be));background-image:-webkit-linear-gradient(top, #35c3d9,#18a7be);background-image:-moz-linear-gradient(top, #35c3d9,#18a7be);background-image:-ms-linear-gradient(top, #35c3d9,#18a7be);background-image:-o-linear-gradient(top, #35c3d9,#18a7be);background-image:linear-gradient(top, #35c3d9,#18a7be);border:solid 1px #1f91a3;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-left-radius:3px;border-bottom-right-radius:3px;border-top-left-radius:3px;border-bottom-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;display:inline-block;vertical-align:middle;color:#fff !important;line-height:43px;text-decoration:none;padding:0 15px;box-shadow:inset 0 1px 0 0 #a0e3ed;text-shadow:0 1px 0 rgba(0,0,0,0.3)}a.ui-button{line-height:34px}.ui-button-middle{height:36px;font-size:1em;line-height:1em}.doublebutton{float:right}.doublebutton a{border:solid 1px #d1d1d1;background-color:#f7f7f7;-webkit-border-radius:2px;border-radius:2px;cursor:default;font-size:11px;font-weight:bold;text-align:center;white-space:nowrap;height:16px;outline:0;padding:5px 6px;display:block;float:left}.doublebutton a span{text-indent:-9999px;float:left;width:16px;height:16px;background-image:

Zen Team

  • Jr. Member
  • **
  • Posts: 51
Re: [TUTORIAL] How to add icons to categories in Bender theme via css
« Reply #2 on: August 01, 2014, 02:21:33 am »
Hi i try edit main.css, but with notepad++ is compacted . ¿How can i edit well?

Use this link:

http://cssbeautify.com/

MarlonCh

  • Newbie
  • *
  • Posts: 8
Re: [TUTORIAL] How to add icons to categories in Bender theme via css
« Reply #3 on: August 01, 2014, 07:36:35 am »
Thanks for  this... I was just about to start working on this on my own.  This will save me a lot of time.

Salvat0re

  • Newbie
  • *
  • Posts: 40
Re: [TUTORIAL] How to add icons to categories in Bender theme via css
« Reply #4 on: August 01, 2014, 12:31:43 pm »
Hi in functions.php i have

Quote
<h1><a class="category <?php echo osc_category_slug() ; ?>" href="<?php echo osc_search_category_url() ; ?>"><?php echo osc_category_name() ; ?></a> <span>(<?php echo osc_category_total_items() ; ?>)</span></h1>

What would be the modified?

Zen Team

  • Jr. Member
  • **
  • Posts: 51
Re: [TUTORIAL] How to add icons to categories in Bender theme via css
« Reply #5 on: August 02, 2014, 01:43:01 am »
Hi in functions.php i have

Quote
<h1><a class="category <?php echo osc_category_slug() ; ?>" href="<?php echo osc_search_category_url() ; ?>"><?php echo osc_category_name() ; ?></a> <span>(<?php echo osc_category_total_items() ; ?>)</span></h1>

What would be the modified?

Code: [Select]
<h1 class="icon_c"><a class="category cat_<?php echo osc_category_id() ; ?>" href="<?php echo osc_search_category_url() ; ?>"><?php echo osc_category_name() ; ?></a><span>(<?php echo osc_category_total_items() ; ?>)</span></h1>
In H1 you will add the class icon_c.
In <a class="category you will add <a class="category  cat_
<?php echo osc_category_slug() ; ?> you will change to <?php echo osc_category_id() ; ?> where you change slug (category name) to ID (category number)

In my version i have removed  <span>(<?php echo osc_category_total_items() ; ?>)</span> because i don't want it to count the numbers of listings.

This is how yours should look like:

Code: [Select]
<h1 class="icon_c"><a class="category cat_<?php echo osc_category_id() ; ?>" href="<?php echo osc_search_category_url() ; ?>"><?php echo osc_category_name() ; ?></a><span>(<?php echo osc_category_total_items() ; ?>)</span></h1>

tuangel

  • Guest
Re: [TUTORIAL] How to add icons to categories in Bender theme via css
« Reply #6 on: October 03, 2014, 06:32:39 pm »
Hello and where I have to upload the pictures I have to create a folder

Zen Team

  • Jr. Member
  • **
  • Posts: 51
Re: [TUTORIAL] How to add icons to categories in Bender theme via css
« Reply #7 on: October 03, 2014, 10:39:03 pm »
you will make a folder or use a existing one. I use img as seen in the css

.active .cat_27{
   background: #228DAC url(/img/house_white.png) no-repeat left !important;
   text-transform:uppercase;
   padding-left:24px;
}

tuangel

  • Guest
Re: [TUTORIAL] How to add icons to categories in Bender theme via css
« Reply #8 on: October 04, 2014, 09:35:49 pm »
theme bender 2.0.1 cannot find the css code   active .cat_27{
   background: #228DAC url(/img/house_white.png) no-repeat left !important;
   text-transform:uppercase;
   padding-left:24px;
}

Zen Team

  • Jr. Member
  • **
  • Posts: 51
Re: [TUTORIAL] How to add icons to categories in Bender theme via css
« Reply #9 on: October 04, 2014, 10:48:18 pm »
you must add the css yourself. please read description again

tuangel

  • Guest
Re: [TUTORIAL] How to add icons to categories in Bender theme via css
« Reply #10 on: October 05, 2014, 06:18:51 am »
last question. css code can I put it where I like more

Zen Team

  • Jr. Member
  • **
  • Posts: 51
Re: [TUTORIAL] How to add icons to categories in Bender theme via css
« Reply #11 on: October 05, 2014, 11:48:50 am »
add css where you want in the css file

keerth

  • Newbie
  • *
  • Posts: 1
Re: [TUTORIAL] How to add icons to categories in Bender theme via css
« Reply #12 on: October 05, 2014, 10:38:42 pm »
This is tutorial on how to add icons to bender theme with classes and css.

First step:

Go to your functions.php and locate this code:
Code: [Select]
<h1><a class="category<?php echo osc_category_slug() ; ?>" href="<?php echo osc_search_category_url() ; ?>"><?php echo osc_category_name() ; ?></a></h1>



im not able to find that line of code
is it in themes/bender
can you mail me the functions.php and main.css file?
this is my email
sq2ind@gmail.com

Zen Team

  • Jr. Member
  • **
  • Posts: 51
Re: [TUTORIAL] How to add icons to categories in Bender theme via css
« Reply #13 on: October 06, 2014, 01:59:04 am »
here are modified function.php which can be found in bender/ and main.css which can be found in bender/css/

Look at bottom main.css
« Last Edit: October 06, 2014, 02:01:32 am by zenteam »

harshahc

  • Newbie
  • *
  • Posts: 16
Re: [TUTORIAL] How to add icons to categories in Bender theme via css
« Reply #14 on: November 25, 2014, 10:19:41 am »
Hi ,

Could you please help me in getting this done for Symnel theme .Its currently using the glaphycons.