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 8 of 8
  1. #1
    Regular Coder
    Join Date
    Oct 2005
    Posts
    336
    Thanks
    43
    Thanked 2 Times in 2 Posts

    Need help with php/joomla frontpage code please

    Hello this is a question regarding php/html, so I am posting in the php forum firstly to see if any help can be suggested

    I am using Joomla 1.5 to design my webpage. I have converted the entire from using Tables to using Divs/Css.

    The last part which I need to convert is on the Frontpage, and is the two vertical columns which display leading articles. This is the only part which is still using tables. I want to convert the table and cell into divs, and keep the same 2-column layout.

    The file is in my Joomla template directory - templates/myjoomlatest/html/frontpage/default.php

    I want to convert the two-column section from tables to divs.
    Here is a link to my page - http://www.tomsspecialreserve.co.uk/joomla
    It is the 6 rounded corner articles in the middle.

    Currently the html output using Firebug to view it is this -

    Code:
    <table width="100%">
    <tbody>
    <tr>
    
    <td class="article_column" width="50%" valign="top">
    <div class="contentpaneopen-tomsroundedcategory">
    </div>
    <div class="contentpaneopen-tomsroundedcategory">
    </div>
    <div class="contentpaneopen-tomsroundedcategory">
    </div>
    </td>
    
    <td class="article_column second_column" width="50%" valign="top">
    <div class="contentpaneopen-tomsroundedcategory">
    </div>
    <div class="contentpaneopen-tomsroundedcategory">
    </div>
    <div class="contentpaneopen-tomsroundedcategory">
    </div>
    
    </td>
    </tr>
    </tbody>
    So there is the outer wrapper table (width100%) and then a cell for the left-hand column (td class="article_column" width 50%). Inside that cell are all the articles. Then there is the right-hand column (td class="article_column second_column" width="50%") which houses all the right hand columns.

    I am hopless with PHP, and I need to know -

    Will changing the columns from tables to divs require any alteration of my Joomla/php code to display the 2 columns? Im asking becuase the php/joomla code outputs as html eg sets up the table columns.

    I have tried to create a 2-colum layout using DIVS for the page, but I dont know how to code the php to get the articles to display in both of the two columns using Divs, and I havent had any luck on the Joomla forum either.

    The php/joomla code for the default.php file is -
    PHP Code:
    <?php // no direct access
    defined('_JEXEC') or die('Restricted access'); ?>
    <?php 
    if ($this->params->get('show_page_title'1)) : ?>
    <div class="componentheading<?php echo $this->params->get('pageclass_sfx'?>">
    <?php echo $this->escape($this->params->get('page_title')); ?>
    </div>
    <?php endif; ?>

    <?php if ($this->params->def('num_leading_articles'1)) : ?>

    <?php else : $i $this->pagination->limitstart; endif; 
    ?>


    <?php
    $startIntroArticles 
    $this->pagination->limitstart $this->params->get('num_leading_articles');
    $numIntroArticles $startIntroArticles $this->params->get('num_intro_articles'4);
    if ((
    $numIntroArticles != $startIntroArticles) && ($i $this->total)) : 
    ?>


    <table width="100%"><?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 ++) :
    if (
    $z 0) : $divider " second_column"; endif; 
    ?>

    <td valign="top" width="<?php echo intval(100 $this->params->get('num_columns')) ?>%" class="article_column<?php echo $divider ?>">
    <?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; 
    ?>

    </td>
    <?php endfor; 
    endif;
    ?>        
    </table>

    <?php endif; ?>
    Can anyone help me with the php code as Im useless with php.
    Last edited by moss2076; 03-18-2009 at 06:48 PM.

  • #2
    Regular Coder
    Join Date
    Oct 2005
    Posts
    336
    Thanks
    43
    Thanked 2 Times in 2 Posts
    Can anyone help me out?

  • #3
    New Coder
    Join Date
    Mar 2009
    Location
    Chicago, IL
    Posts
    69
    Thanks
    0
    Thanked 15 Times in 15 Posts
    Try replacing this code:

    PHP Code:
    <table width="100%"><?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 ++) :
    if (
    $z 0) : $divider " second_column"; endif; 
    ?>

    <td valign="top" width="<?php echo intval(100 $this->params->get('num_columns')) ?>%" class="article_column<?php echo $divider ?>">
    <?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; 
    ?>

    </td>
    <?php endfor; 
    endif;
    ?>        
    </table>

    With this one:

    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>

  • Users who have thanked steelaz for this post:

    moss2076 (03-18-2009)

  • #4
    Regular Coder
    Join Date
    Oct 2005
    Posts
    336
    Thanks
    43
    Thanked 2 Times in 2 Posts
    Thankyou for replying, im pulling my hair out - seriously!

    I replaced the table section of code with your code, but get a php generated error message. Im sorry my php isnt good enough to even begin working it out -
    PHP Code:
    Parse errorsyntax errorunexpected T_IF in E:domainsttomsspecialreserve.co.ukuserhtdocsjoomlatemplatestoms_joomla_testhtmlcom_contentfrontpagedefault.php on line 26 
    Line 26 of my article.php is
    PHP Code:
    $float_direction = if ($z 0) ? 'right' 'left'
    .
    Last edited by moss2076; 03-18-2009 at 10:11 PM.

  • #5
    New Coder
    Join Date
    Mar 2009
    Location
    Chicago, IL
    Posts
    69
    Thanks
    0
    Thanked 15 Times in 15 Posts
    My bad, this line should be:

    PHP Code:
    $float_direction = ($z 0) ? 'right' 'left'

  • Users who have thanked steelaz for this post:

    moss2076 (03-18-2009)

  • #6
    Regular Coder
    Join Date
    Oct 2005
    Posts
    336
    Thanks
    43
    Thanked 2 Times in 2 Posts
    That has sorted it!!

    Have a look if you want - http://www.tomsspecialreserve.co.uk/joomla

    Can I be really pushy and ask if it is actually possible to name the wrapper div, and the left and right column divs eg name them div id="PrimaryColumn", div id="SecondaryColumn", and place their width settings in a CSS file instead of in the markup, or am I is that not an option becuase of the php code?

    I wish I could learn php, but it just doesnt sink in for me.

  • #7
    New Coder
    Join Date
    Mar 2009
    Location
    Chicago, IL
    Posts
    69
    Thanks
    0
    Thanked 15 Times in 15 Posts
    No problem, just don't forget that "Thank you" button

    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 = if ($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>
    Now you have wrapper div as "PrimaryColumn", then "LeftColumn" and "RightColumn".

  • Users who have thanked steelaz for this post:

    moss2076 (03-18-2009)

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

    You are a true genius! I wish I knew what you knew, thankyou so much.

    I will start a new thread tomorrow as I need to work out why my leading articles at the top of the frontpage wont display, but getting the columns to display with divs/css is more than enough for one day


  •  

    Posting Permissions

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