lundi 28 mars 2016

Issue setting article newsflash into a table

Hi I am trying to turn article newsflash into a list of links in a table. I remove intro text by commenting it out so that it will only show the article title, and alter the tmpl files.

This is a php file called links. I duplicated vertical.php from modules/mod_article_news and then put this info instead.

<?php
/**
 * @package             Joomla.Site
 * @subpackage  mod_articles_news
 * @copyright   Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
 * @license             GNU General Public License version 2 or later; see LICENSE.txt
 */

// no direct access
defined('_JEXEC') or die; 

echo '<div class="newsflash-vert">';
for ($i = 0, $n = count($list); $i < $n; $i ++) {
        $item = $list[$i]; 
if ($i==0){
echo "<table>";
}

if ($i & 1){
//odd
}else{
//even
echo "<tr>";
}
echo "<td>";
        echo '<div class="newsflash-item">';
         require JModuleHelper::getLayoutPath('mod_articles_news', '_item_links');
        if ($n > 1 && (($i < $n - 1) || $params->get('showLastSeparator'))) {
                echo '<span class="article-separator">&#160;</span>';
        }
        echo '</div>';

echo "</td>";
if ($i & 1){
//odd
}else{

if ($i == $n){
echo "</tr>";
}
}
if ($i == $n){
//end
echo "</table>";
}
}
echo "</div>";

I also duplicatied _item.php and renamed it to _item_links and have this php code:

<?php
/**
 * @package             Joomla.Site
 * @subpackage  mod_articles_news
 * @copyright   Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
 * @license             GNU General Public License version 2 or later; see LICENSE.txt
 */

// no direct access
defined('_JEXEC') or die;
$item_heading = $params->get('item_heading', 'h4');
?>
<?php if ($params->get('item_title')) : ?>

        <<?php echo $item_heading; ?> class="newsflash-title<?php echo $params->get('moduleclass_sfx'); ?>">
        <?php if ($params->get('link_titles') && $item->link != '') : ?>
                <a href="<?php echo $item->link;?>">
                        <?php echo $item->title;?></a>
        <?php else : ?>
                <?php echo $item->title; ?>
        <?php endif; ?>
        </<?php echo $item_heading; ?>>

<?php endif; ?>

<?php if (!$params->get('intro_only')) :
        echo $item->afterDisplayTitle;
endif; ?>

<?php echo $item->beforeDisplayContent; ?>

<?php //echo $item->introtext; ?>

<?php if (isset($item->link) && $item->readmore != 0 && $params->get('readmore')) :
        echo '<a class="readmore" href="'.$item->link.'">'.$item->linkText.'</a>';
endif; ?>

Then I was going to make it look nicer with css, but I am getting an error in my error_log: [29-Mar-2016 00:19:58 America/New_York] PHP Notice: Trying to get property of non-object in /home/loverevo/public_html/clearlove/templates/clearlove_home/html/com_content/article/view.html.php on line 217

This error goes away when I put the file back, I believe it has something to do with my if statements. But I am not sure. I also tried the code with out having it all as php, and using a lot of leaving all the html as just html and not echoed.

Not sure what is causing this, any one have any ideas?

Aucun commentaire:

Enregistrer un commentaire