0 Пользователей и 1 Гость просматривают эту тему.
  • 3 Ответов
  • 2826 Просмотров
*

Rezet

  • Захожу иногда
  • 57
  • 1 / 0
Шаблонизация frontpage
« : 08.06.2009, 15:18:55 »
Делаю собственный шаблон для frontpage. Почему-то отображается только 1ая новость... следующая новость не выводится, выводится только её html структура без текста... Подскажите пожалуйста, где я тут накосячил?)
мой default.php
Код
<?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; ?>
<div class="blog<?php echo $this->params->get('pageclass_sfx') ?>">
<?php if ($this->params->def('num_leading_articles', 1)) : ?>


    <div class="article">
        <?php for ($i = $this->pagination->limitstart; $i < ($this->pagination->limitstart + $this->params->get('num_leading_articles')); $i++) : ?>
            <?php if ($i >= $this->total) : break; endif; ?>
            <?php
                $this->item =& $this->getItem($i, $this->params);
                echo $this->loadTemplate('item');
            ?>

<?php endfor; ?>
</div>
<?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)) : ?>

    <div class="article">
<?php $this->item =& $this->getItem($target, $this->params);
  echo $this->loadTemplate('item');?>

</div>
<?php endif; ?>



</div>

мой default_item следующий:
Код
<?php // no direct access
defined('_JEXEC') or die('Restricted access');

$canEdit = ($this->user->authorize('com_content', 'edit', 'content', 'all') || $this->user->authorize('com_content', 'edit', 'content', 'own'));
?>


<?php if ($this->item->state == 0) : ?>
    <div class="system-unpublished">
<?php endif; ?>



<?php if ($this->item->params->get('show_title')) : ?>
<div class="articletitle">
                  <div>
                                               <div>
                                                    <span class="createdate">
                                                 <?php echo JHTML::_('date', $this->item->created, JText::_('DATE_FORMAT_LC2')); ?>
                                                    </span>
                                                    <span class="title<?php echo $this->item->params->get( 'pageclass_sfx' ); ?>">
<?php if ($this->item->params->get('link_titles') && $this->item->readmore_link != '') : ?>

                                                     <a href="<?php echo $this->item->readmore_link; ?>" class="contentpagetitle<?php echo $this->item->params->get( 'pageclass_sfx' ); ?>">
                                                        <?php echo $this->item->title; ?></a>
                                                    <?php else : ?>
                                                        <?php echo $this->escape($this->item->title); ?>
                                                    <?php endif; ?>
                                                    </span>
                                                    
                                                </div>
                                              </div>
                                            </div>
                                            <?php if ($this->item->params->get('show_category') && $this->item->catid) : ?><span class="label"><span><span><span>
                      
                            <?php if ($this->item->params->get('link_category')) : ?>
                                <?php echo '<a href="'.JRoute::_(ContentHelperRoute::getCategoryRoute($this->item->catslug, $this->item->sectionid)).'">'; ?>
                            <?php endif; ?>
                            <?php echo $this->item->category; ?>
                            <?php if ($this->item->params->get('link_category')) : ?>
                                <?php echo '</a>'; ?>
                            <?php endif; ?>
                      
                        </span></span></span></span><?php endif; ?>





<?php if ($canEdit) : ?>
<div>
<?php echo JHTML::_('icon.edit', $this->item, $this->item->params, $this->access); ?>
</div>
<?php endif; ?>



<?php endif; ?>



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

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

<div class="articletext<?php echo $this->item->params->get( 'pageclass_sfx' ); ?>">
<?php if (isset ($this->item->toc)) : ?>
<?php echo $this->item->toc; ?>
<?php endif; ?>
<br />
<?php echo $this->item->text; ?>
</div>



<?php if ($this->item->params->get('show_readmore') && $this->item->readmore) : ?>
<a class="more<?php echo $this->item->params->get('pageclass_sfx'); ?>" href="<?php echo $this->item->readmore_link; ?>">
<?php if ($this->item->readmore_register) :
echo JText::_('Register to read more...');
elseif ($readmore = $this->item->params->get('readmore')) :
echo $readmore;
else :
echo JText::sprintf('Read more...');
endif; ?></a>

<?php endif; ?>


<?php if ($this->item->state == 0) : ?>
</div>
<?php endif; ?>
<div class="spacer"></div>
<?php echo $this->item->event->afterDisplayContent; ?>
« Последнее редактирование: 08.06.2009, 15:30:08 от Rezet »
*

Rezet

  • Захожу иногда
  • 57
  • 1 / 0
Re: Шаблонизация frontpage
« Ответ #1 : 08.06.2009, 15:20:33 »
2ая новость выглядит так, а последующие вовсе отсутствуют:
Код
<div class="article">
<div class="system-unpublished">
    
                  <div class="articletitle">
                            <div>
                                     <div>
                                                 <span class="createdate">
                                                 08.06.09 14:03
                                                    </span>
                                                    <span class="title">
                                                                                                                                                               </span>
                                                    
                                                </div>
                                              </div>
                                            </div>
                                            







<div class="articletext">

<br>
</div>





</div>
<div class="spacer"></div>

</div>



Избавился от 2ой - косяченной новости сократив код default.php

Код
<?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; ?>
<div class="blog<?php echo $this->params->get('pageclass_sfx') ?>">


    <div class="article">
        <?php for ($i = $this->pagination->limitstart; $i < ($this->pagination->limitstart + $this->params->get('num_leading_articles')); $i++) : ?>
            <?php if ($i >= $this->total) : break; endif; ?>
            <?php
                $this->item =& $this->getItem($i, $this->params);
                echo $this->loadTemplate('item');
            ?>

<?php endfor; ?>
</div>




</div>

Видимо, у меня выводится только лидирующая новость, как изменить кол-во лидирующих новостей?
« Последнее редактирование: 08.06.2009, 15:36:05 от Rezet »
*

Rezet

  • Захожу иногда
  • 57
  • 1 / 0
Re: Шаблонизация frontpage
« Ответ #2 : 08.06.2009, 17:16:01 »
я - чудо программер))
Код
 
<?php for ($i = $i + 1; ; $i++) : ?>
            <?php if ($i >= $this->total) : break; endif; ?>
            <?php
                $this->item =& $this->getItem($i, $this->params);
                echo $this->loadTemplate('item');
            ?>

<?php endfor; ?>
Заработало вроде
*

Rezet

  • Захожу иногда
  • 57
  • 1 / 0
Re: Шаблонизация frontpage
« Ответ #3 : 08.06.2009, 17:38:33 »
В предыдущем коде теряется одна новость, переделал:
Код
<?php for ($i = $this->pagination->limitstart; ; $i++) : ?>
            <?php if ($i >= $this->total) : break; endif; ?>
            <?php
                $this->item =& $this->getItem($i, $this->params);
                echo $this->loadTemplate('item');
            ?>

<?php endfor; ?>
Тему можно закрывать)
« Последнее редактирование: 08.06.2009, 19:03:01 от Rezet »
Чтобы оставить сообщение,
Вам необходимо Войти или Зарегистрироваться
 

Шаблонизация компонентов в Joomla1.5. Первый взгляд.

Автор userxp

Ответов: 29
Просмотров: 24117
Последний ответ 30.01.2011, 23:56:42
от shprota