Reg Gordon
Reg Gordon

Reputation: 253

Adding Div Classes To PHP Lists

Hello I have some php which is generating a list for me. I added the

  • bits myself and was quite pleased with it actually doing something than giving m a php error

        <?php
        $termid = arg(2);
        $terms = taxonomy_get_related($termid, $key = 'tid');
        //print_r($terms);
        foreach($terms as $term){
    
           $link = url('taxonomy/term/'.$term->tid);
           echo '<li><a href="'.$link.'">'.$term->name.'</a></li>';
         }
      ?>
    

    I was wanting to style my list though and tried -

        <div class="sidey"><?php
        $termid = arg(2);
        $terms = taxonomy_get_related($termid, $key = 'tid');
        //print_r($terms);
        foreach($terms as $term){
    
           $link = url('taxonomy/term/'.$term->tid);
           echo '<li><a href="'.$link.'">'.$term->name.'</a></li>';
         }
      ?></div>
    

    with-

       .sidey .inner ul li, .sidey .view-content div.views-row {
        border-bottom-color: #DDDDDD;
    list-style-image: none;
    line-height: 130%;
        padding: 5px 0;
     border-bottom-style: solid;
        border-bottom-width: 1px;
    }
    

    but to no effect. Should this work or am i missing something very fundamental here? I think i am. Also tried this but again to no avail-

        <?php
        $termid = arg(2);
        $terms = taxonomy_get_related($termid, $key = 'tid');
        //print_r($terms);
        foreach($terms as $term){
    
           $link = url('taxonomy/term/'.$term->tid);
           echo '<div id="sidey"><li><a href="'.$link.'">'.$term->name.'</a></li></div>';
         }
      ?>
    

    Could anyone point me in the right direction? Thanks

    Upvotes: 1

    Views: 94

  • Answers (2)

    Alberto Ponte
    Alberto Ponte

    Reputation: 479

    If you are going to assign an ID to the div then make sure you open and close your UL (like someone mentioned below), then your CSS should be:

    div#sidey ul li {
        border-bottom-color: #DDDDDD;
        list-style-image: none;
        line-height: 130%;
        padding: 5px 0;
         border-bottom-style: solid;
        border-bottom-width: 1px;
    }
    

    Upvotes: 0

    v0d1ch
    v0d1ch

    Reputation: 2748

    You are missing the beginning and ending of unordered list <ul></ul>

    Upvotes: 3

    Related Questions