Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • kansen Friend
    #154434

    hello

    now in my frontpage and blog view pages my articles are listed like

    but i need to set some banners or images each 2 or 3 items on the list like this

    how can i manage the arry of articles listed?
    any clue?

    thanks


    1. 2
    2. 3
    Saguaros Moderator
    #356026

    now, you open the file: templatesTEMPLATE NAMEhtmlcom_contentfrontpagedefault.php and find the following code:
    [PHP]
    echo $this->loadTemplate(‘item’); ?>
    </div>

    <?php endfor; ?>
    [/PHP]

    replace:
    [PHP]
    echo $this->loadTemplate(‘item’); ?>
    </div>

    <?php echo $i;?><div class=”test”><jdoc:include type=”modules” style=”raw” name=”banner-<?php echo $i;?>” /></div>
    <?php endfor; ?>
    [/PHP]

    When done, each article has a new position:
    for example: article 1: it’s banner-0 position, now, you put your module on there

    kansen Friend
    #356302

    hello, thanks for reply

    i got your point of view, i copied the code as you said in default.php,

    <div class="article_row<?php echo $this->escape($this->params->get('pageclass_sfx')); ?> cols<?php echo $colcount; ?> clearfix">
    <?php for ($z = 0; $z < $colcount && $ii < $introcount && $i < $this->total; $z++, $i++, $ii++) : ?>
    <div class="article_column column<?php echo $z + 1; ?>" >
    <?php $this->item =& $this->getItem($i, $this->params);
    echo $this->loadTemplate('item'); ?>

    </div>

    <?php echo $i;?><div class="test"><jdoc:include type="modules" style="raw" name="banner-<?php echo $i;?>" /></div>

    <?php endfor; ?>

    </div>

    it works in someway, it show the $i values from the for

    8949

    it show the module name too in the web code

    8948

    i set the position of a test module with a picture in admin and save

    8947

    but it doesnt show anything on frontpage or web code

    what could be missing?

    cheers


    1. j3
    2. j2
    3. j1
    billyk Friend
    #377486

    did you ever get this figured out? all i see are numbers now

    <em>@kansen 194997 wrote:</em><blockquote>hello, thanks for reply

    i got your point of view, i copied the code as you said in default.php,

    <div class="article_row<?php echo $this->escape($this->params->get('pageclass_sfx')); ?> cols<?php echo $colcount; ?> clearfix">
    <?php for ($z = 0; $z < $colcount && $ii < $introcount && $i < $this->total; $z++, $i++, $ii++) : ?>
    <div class="article_column column<?php echo $z + 1; ?>" >
    <?php $this->item =& $this->getItem($i, $this->params);
    echo $this->loadTemplate('item'); ?>

    </div>

    <?php echo $i;?><div class="test"><jdoc:include type="modules" style="raw" name="banner-<?php echo $i;?>" /></div>

    <?php endfor; ?>

    </div>

    it works in someway, it show the $i values from the for

    8949

    it show the module name too in the web code

    8948

    i set the position of a test module with a picture in admin and save

    8947

    but it doesnt show anything on frontpage or web code

    what could be missing?

    cheers</blockquote>

    Saguaros Moderator
    #377675

    You open : templatesTEMPLATE NAMEhtmlcom_contentfrontpagedefault.php and find:

    [PHP]defined(‘_JEXEC’) or die(‘Restricted access’);[/PHP]

    replace by:

    [PHP]
    defined(‘_JEXEC’) or die(‘Restricted access’);
    function loadModulesByPosition( $position=” ){
    $modules = JModuleHelper::getModules( $position );
    if( $modules ) {
    $document = &JFactory::getDocument();
    $renderer = $document->loadRenderer(‘module’);
    $output=”;
    foreach( $modules as $module ){
    $output .= ‘<div class=”lof-module”>’.$renderer->render( $module, array(‘style’ => ‘raw’) ).'</div>’;
    }
    return $output;
    }
    return ;
    }

    [/PHP]

    and then find:
    [PHP]
    echo $this->loadTemplate(‘item’); ?>
    [/PHP]

    Replace with :
    [PHP]
    echo $this->loadTemplate(‘item’); ?>
    <?php echo loadModulesByPosition( ‘banner-‘.$i ); ?>
    [/PHP]

    pablofw Friend
    #394371

    <em>@tienhc 222795 wrote:</em><blockquote>You open : templatesTEMPLATE NAMEhtmlcom_contentfrontpagedefault.php and find:

    [PHP]defined(‘_JEXEC’) or die(‘Restricted access’);[/PHP]

    replace by:

    [PHP]
    defined(‘_JEXEC’) or die(‘Restricted access’);
    function loadModulesByPosition( $position=” ){
    $modules = JModuleHelper::getModules( $position );
    if( $modules ) {
    $document = &JFactory::getDocument();
    $renderer = $document->loadRenderer(‘module’);
    $output=”;
    foreach( $modules as $module ){
    $output .= ‘<div class=”lof-module”>’.$renderer->render( $module, array(‘style’ => ‘raw’) ).'</div>’;
    }
    return $output;
    }
    return ;
    }

    [/PHP]

    and then find:
    [PHP]
    echo $this->loadTemplate(‘item’); ?>
    [/PHP]

    Replace with :
    [PHP]
    echo $this->loadTemplate(‘item’); ?>
    <?php echo loadModulesByPosition( ‘banner-‘.$i ); ?>
    [/PHP]</blockquote>
    tried and i get this error “Parse error: syntax error, unexpected T_VARIABLE” maybe from typos on the code?

    any help fixing the code would be greatly appreciated.

    pablofw Friend
    #398514

    i think i got it working but only for intro articles, how can we use this for articles on colums?

    chavan Friend
    #398549

    Hi pablofw

    You add this code


    <?php echo loadModulesByPosition( 'banner-'.$y ); ?>

    after


    <div class="items-row cols-<?php echo $colcount; ?> row-<?php echo $y ?> clearfix">
    <?php for ($z = 0; $z < $colcount && $ii < $introcount && $i < $this->total; $z++, $i++, $ii++) : ?>
    <div class="item column<?php echo $z; ?>" >
    <?php $this->item =& $this->getItem($i, $this->params);
    echo $this->loadTemplate('item'); ?>
    </div>
    <?php endfor; ?>
    </div>

    pablofw Friend
    #402593

    thanks for the reply dohq

    my default.php is different from the one you posted, could you please show me how to put your code here? i’m desperate!

    // init vars
    $count = min($this->params->get('num_intro_articles', 4), ($this->total - $i));
    $rows = ceil($count / $this->params->get('num_columns', 2));
    $columns = array();

    // create intro columns
    for ($j = 0; $j < $count; $j++, $i++) {

    if ($this->params->get('multi_column_order', 1) == 0) {
    // order down
    $column = intval($j / $rows);
    } else {
    // order across
    $column = $j % $this->params->get('num_columns', 2);
    }

    if (!isset($columns[$column])) {
    $columns[$column] = '';
    }

    $this->item =& $this->getItem($i, $this->params);
    $columns[$column] .= $this->loadTemplate('item');
    }

    // render intro columns
    $count = count($columns);
    if ($count) {
    if ($count != 1) {
    echo '<div class="teaserarticles multicolumns">';
    } else {
    echo '<div class="teaserarticles">';
    }
    for ($j = 0; $j < $count; $j++) {
    $firstlast = "";
    if ($count != 1) {
    if ($j == 0) $firstlast = "first";
    if ($j == $count - 1) $firstlast = "last";
    }
    echo '<div class="'.$firstlast.' float-left width'.intval(100 / $count).'">'.$columns[$j].'</div>';
    }
    echo '</div>';
    }
    }
    ?>

    chavan Friend
    #402602

    Hi pablofw

    You should try paste in end of this block code


    for ($j = 0; $j < $count; $j++, $i++) {

    if ($this->params->get('multi_column_order', 1) == 0) {
    // order down
    $column = intval($j / $rows);
    } else {
    // order across
    $column = $j % $this->params->get('num_columns', 2);
    }

    if (!isset($columns[$column])) {
    $columns[$column] = '';
    }

    $this->item =& $this->getItem($i, $this->params);
    $columns[$column] .= $this->loadTemplate('item');
    }

    or


    $count = count($columns);
    if ($count) {
    if ($count != 1) {
    echo '<div class="teaserarticles multicolumns">';
    } else {
    echo '<div class="teaserarticles">';
    }
    for ($j = 0; $j < $count; $j++) {
    $firstlast = "";
    if ($count != 1) {
    if ($j == 0) $firstlast = "first";
    if ($j == $count - 1) $firstlast = "last";
    }
    echo '<div class="'.$firstlast.' float-left width'.intval(100 / $count).'">'.$columns[$j].'</div>';
    }
    echo '</div>';
    }

    pablofw Friend
    #402720

    solved the problem, im stupid XD

Viewing 11 posts - 1 through 11 (of 11 total)

This topic contains 11 replies, has 5 voices, and was last updated by  pablofw 13 years, 4 months ago.

We moved to new unified forum. Please post all new support queries in our New Forum