Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder
    Join Date
    Oct 2005
    Posts
    336
    Thanks
    43
    Thanked 2 Times in 2 Posts

    Columns not displaying correctly - help needed please

    Hello,

    I need some help tweeking the code below. I am trying to use the code with Joomla 1.5 to display frontpage / blog layouts in either a single 100% width'PrimaryColumn' , or in two 50% column widths ('leftColumn' and 'rightColumn').

    In the Joomla admin section I can select either one or two columns to be outputted by the code.

    The probelm is this -

    If I select one column to be outputted the 'leftColumn' 50% width is displayed - But it should be the outer "PrimaryColumn" which is displayed, and 'leftColumn' should not be displayed at all.

    If I select two columns to be outputted I need the PrimaryColumn to be displayed as a wrapper, and then the leftColumn and rightColumn displayed at 50% width each inside the wrapper.

    Here is my code, if anyone could have a look and help me out I would appreciate it! -

    PHP Code:
    <div class="PrimaryColumn">
    <? 
    if ($this->params->def('multi_column_order',1)):
        
    $i $i $this->params->get('num_intro_articles'); 
    else: 
        for (
    $z 0$z $this->params->get('num_columns'); $z ++) :
            
    $column_class =($z 0) ? 'RightColumn' 'LeftColumn';
            
            echo 
    '<div class="'.$column_class.'">';
            
            for (
    $y 0$y < ($this->params->get('num_intro_articles') / $this->params->get('num_columns')); $y ++) :
                if (
    $i $this->total && $i < ($numIntroArticles)) :
                    
    $this->item =& $this->getItem($i$this->params);
                    echo 
    $this->loadTemplate('item');
                    
    $i ++;
                endif;
            endfor; 
        
            echo 
    '</div>';

        endfor; 
    endif;
    ?>        
    </div>

  • #2
    Senior Coder tomws's Avatar
    Join Date
    Nov 2007
    Location
    Arkansas
    Posts
    2,644
    Thanks
    29
    Thanked 330 Times in 326 Posts
    Well, if it's printing left or right inside of primary, then it must be entering the else statement. Find out why.

    A quick glance at the Joomla documentation for def() suggests that it returns the set param value (the value that was already set, or the value if this is a new param). Now, if you're setting a new param multi_column_order, it should return 1 and the program should enter the if. That implies that it's returning zero, or null, or an empty string, which further implies that the param is already set. Is it?

    You should be able to tell by looking at the db (Drupal stores things like that in the db, anyway). If not, echo/print/dump the get() value before the if/else. If is is set prior to this point, you may need to test against that value rather than using the bare def() return value, or test against the get() instead.
    Are you a Help Vampire?

  • #3
    Regular Coder
    Join Date
    Oct 2005
    Posts
    336
    Thanks
    43
    Thanked 2 Times in 2 Posts
    Update -

    I also have this code which does display the columns correctly, but uses inline widths in the code instead of seperate CSS. I am trying to keep my CSS seperate.

    Could this code be adjusted to eliminate the inline widths so it uses external CSS? I have the CSS, just need to adjust this code accordingly, but Im not sure how -
    PHP Code:
    <div style="width: 100%; overflow: hidden;"><?php $divider ''; if ($this->params->def('multi_column_order',1)) : 
    $i $i $this->params->get('num_intro_articles') ;  
    else :  
    for (
    $z 0$z $this->params->get('num_columns'); $z ++) : 
    $float_direction = if ($z 0) ? 'right' 'left'
    $column_width intval(100 $this->params->get('num_columns')); 
    ?> 

    <div style="width:<?= $column_width ?>%; float:<?= $float_direction ?>"> 
    <?php for ($y 0$y < ($this->params->get('num_intro_articles') / $this->params->get('num_columns')); $y ++) : 
    if (
    $i $this->total && $i < ($numIntroArticles)) : 
    $this->item =& $this->getItem($i$this->params); 
    echo 
    $this->loadTemplate('item'); 
    $i ++; 
    endif; 
    endfor;  
    ?> 

    </div> 
    <?php endfor;  
    endif;
    ?>         
    </div>

  • #4
    Senior Coder tomws's Avatar
    Join Date
    Nov 2007
    Location
    Arkansas
    Posts
    2,644
    Thanks
    29
    Thanked 330 Times in 326 Posts
    Use a class or an ID?
    Are you a Help Vampire?

  • #5
    Regular Coder
    Join Date
    Oct 2005
    Posts
    336
    Thanks
    43
    Thanked 2 Times in 2 Posts
    Quote Originally Posted by tomws View Post
    Use a class or an ID?
    That is what I had in the first code example which wasn't quite working correcty.

  • #6
    Senior Coder tomws's Avatar
    Join Date
    Nov 2007
    Location
    Arkansas
    Posts
    2,644
    Thanks
    29
    Thanked 330 Times in 326 Posts
    That one had a class. Try using an ID. Or try using a longer identifier string. Sometimes earlier CSS will take precedence over later CSS cimply because it's more specific to the element in question. For example, rather than using .Primary, isolate it a bit more:
    Code:
    div#content div.Post div.Primary 
    {
      /*My CSS here.*/
    }
    Not sure if that's your problem, but I see that issue when modifying Drupal themes.
    Are you a Help Vampire?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •