Programming Question:

Discussion in 'HTML & Website Design' started by Zero2HeroBlogger, Jul 23, 2009.

  1. #1
    OK I am wondering if its possible to have my blog display two different kinds/styles of posts in the same page just by changing with category it is in or by some other method.

    For instance, when it is a normal post there is a picture thumbnail and the excerpt is displayed. When I want to post a video I do not know how to not use the thumbnail image not show up.

    I want to know if there is some kind of logic I can use to say

    if (category = video)
    div class = video class

    else (category != video)
    div class = normal class

    I know the logic should work but I'm pretty new to PHP, can anyone out there lend me their brains???
     
    Zero2HeroBlogger, Jul 23, 2009 IP
  2. nontemplates

    nontemplates Peon

    Messages:
    782
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Are you using wordpress for your blog? If so it doesn't even require writing your own programming logic. The proper wordpress tags along with some custom fields will get you easily to where you want to go.
     
    nontemplates, Jul 24, 2009 IP
  3. Kerosene

    Kerosene Alpha & Omega™ Staff

    Messages:
    11,366
    Likes Received:
    575
    Best Answers:
    4
    Trophy Points:
    385
    #3
    Try something like this:

    <?php
    $mycategory = get_the_category();
    $mycategory = $mycategory[0]->cat_name;
    $mydiv='normal';
    if ($mycategory=='Video'){$mydiv='video';}
    ?>

    <div class="<? echo $mydiv; ?>">blabla</div>

    EDIT - I assume you are using Wordpress. If you're not, you should be :D
     
    Last edited: Jul 24, 2009
    Kerosene, Jul 24, 2009 IP