Recent searches


No recent searches

Home Page Category Display - How to Write If/Then/Else



Posted May 24, 2024

Hi guys, I'm having a basic conundrum..I'd like to pick out one of my categories using an if/then in my home page code, and style that category box differently than the rest. What is the procedure for writing if/thens and referencing a category?

 

Thanks in advance!


0

3

3 comments

Tim Gilbreath You can try something like this:
<div id="main-content"
  {{#is category.id 360000123456}} class="my-first-class"

  {{else}}

    {{#is category.id 360000888444}} class="my-second-class"

    {{else}}

      {{!-- do more stuff here --}}

    {{/is}}

  {{/is}}
>

0


Hmm for some reason that's giving me an error saying it either can't use #is in that manner, or that ID is not available in category.

 

This is the block of code I'm trying to run it on, basically I want one category to have a different style:

I discovered that <li class="blocks-item" id="{{id}}"> is the item that I need to style, which I've already created in the style sheet.

 <ul class="blocks-list">
           {{#each categories}}
             {{#if ../has_multiple_categories}}
               <li class="blocks-item" id="{{id}}">
                 <a href='{{url}}' class="blocks-item-link">
                   <span class="category-icon"></span>
                   <span class="blocks-item-title">{{name}}</span>
                   <span class="blocks-item-description">{{excerpt description characters=150}}</span>
                 </a>
               </li>
             {{else}}
               {{#each sections}}
                 <li class="blocks-item" id="{{id}}">
                   <a href='{{url}}' class="blocks-item-link">
                     <span class="category-icon"></span>
                     <span class="blocks-item-description">{{excerpt description characters=150}}</span>
                     <span class="blocks-item-title">
                       {{name}}
                     </span>
                   </a>
                 </li>
               {{/each}}
             {{/if}}
           {{/each}}
         </ul>

0


Tim Gilbreath I used this in 'templates/category_page.hbs'

0


Please sign in to leave a comment.

Didn't find what you're looking for?

New post