...

View Full Version : Columns not displaying correctly - help needed please



moss2076
01-16-2010, 12:42 PM
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!:) -



<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>

tomws
01-16-2010, 03:15 PM
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() (http://api.joomla.org/Joomla-Framework/Parameter/JParameter.html#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.

moss2076
01-16-2010, 04:35 PM
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 -


<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>

tomws
01-16-2010, 10:09 PM
Use a class or an ID?

moss2076
01-16-2010, 10:16 PM
Use a class or an ID?

That is what I had in the first code example which wasn't quite working correcty.

tomws
01-16-2010, 10:56 PM
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:

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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum