今天对joomla k2的功能及布局做了一个小小的研究与更改,在这边记录一下,以备后用。
原来的k2内容展示页的显示顺序大概是这个样子的:1、标题;2、按钮之类;3、介绍;4、全文;5、额外字段;(不做一一列举)........最后才是图库展示。但似乎不符合我们接受的一般规律,我这次建的是一家短租公寓网站:3c-home.com.希望能直观的先显示图库,再显示额外字段,然后显示其他的,然后我找k2的源代码做个修改。
一、item.php文件的修改
既然是文章显示,应该就是修改\components\com_k2\templates\default\item.php这个文件喽,来看一下部分源代码:
<!-- Start K2 Item Layout -->
<span id="startOfPageId<?php echo JRequest::getInt('id'); ?>"></span>
<div id="k2Container" class="itemView<?php echo ($this->item->featured) ? ' itemIsFeatured' : ''; ?><?php if($this->item->params->get('pageclass_sfx')) echo ' '.$this->item->params->get('pageclass_sfx'); ?>">
<!-- Plugins: BeforeDisplay -->
<?php echo $this->item->event->BeforeDisplay; ?>
<!-- K2 Plugins: K2BeforeDisplay -->
<?php echo $this->item->event->K2BeforeDisplay; ?>
<div class="itemHeader">
<?php if($this->item->params->get('itemDateCreated')): ?>
<!-- Date created -->
<span class="itemDateCreated">
<?php echo JHTML::_('date', $this->item->created , JText::_('K2_DATE_FORMAT_LC2')); ?>
</span>
<?php endif; ?>
<?php if($this->item->params->get('itemTitle')): ?>
<!-- Item title -->
<h2 class="itemTitle">
<?php if(isset($this->item->editLink)): ?>
<!-- Item edit link -->
<span class="itemEditLink">
<a class="modal" rel="{handler:'iframe',size:{x:990,y:550}}" href="<?php echo $this->item->editLink; ?>">
<?php echo JText::_('K2_EDIT_ITEM'); ?>
</a>
</span>
<?php endif; ?>
<?php echo $this->item->title; ?>
<?php if($this->item->params->get('itemFeaturedNotice') && $this->item->featured): ?>
<!-- Featured flag -->
<span>
<sup>
<?php echo JText::_('K2_FEATURED'); ?>
</sup>
</span>
<?php endif; ?>
</h2>
<?php endif; ?>
<?php if($this->item->params->get('itemAuthor')): ?>
<!-- Item Author -->
<span class="itemAuthor">
<?php echo K2HelperUtilities::writtenBy($this->item->author->profile->gender); ?>
<?php if(empty($this->item->created_by_alias)): ?>
<a rel="author" href="<?php echo $this->item->author->link; ?>"><?php echo $this->item->author->name; ?></a>
<?php else: ?>
<?php echo $this->item->author->name; ?>
<?php endif; ?>
</span>
<?php endif; ?>
</div>
<!-- Plugins: AfterDisplayTitle -->
<?php echo $this->item->event->AfterDisplayTitle; ?>
<!-- K2 Plugins: K2AfterDisplayTitle -->
<?php echo $this->item->event->K2AfterDisplayTitle; ?>
<?php if(
$this->item->params->get('itemFontResizer') ||
$this->item->params->get('itemPrintButton') ||
$this->item->params->get('itemEmailButton') ||
$this->item->params->get('itemSocialButton') ||
$this->item->params->get('itemVideoAnchor') ||
$this->item->params->get('itemImageGalleryAnchor') ||
$this->item->params->get('itemCommentsAnchor')
): ?>
<div class="itemToolbar">
<ul>
<?php if($this->item->params->get('itemFontResizer')): ?>
<!-- Font Resizer -->
<li>
<span class="itemTextResizerTitle"><?php echo JText::_('K2_FONT_SIZE'); ?></span>
<a href="#" id="fontDecrease">
<span><?php echo JText::_('K2_DECREASE_FONT_SIZE'); ?></span>
<img src="<?php echo JURI::root(true); ?>/components/com_k2/images/system/blank.gif" alt="<?php echo JText::_('K2_DECREASE_FONT_SIZE'); ?>" />
</a>
<a href="#" id="fontIncrease">
<span><?php echo JText::_('K2_INCREASE_FONT_SIZE'); ?></span>
<img src="<?php echo JURI::root(true); ?>/components/com_k2/images/system/blank.gif" alt="<?php echo JText::_('K2_INCREASE_FONT_SIZE'); ?>" />
</a>
</li>
<?php endif; ?>
<?php if($this->item->params->get('itemPrintButton') && !JRequest::getInt('print')): ?>
<!-- Print Button -->
<li>
<a class="itemPrintLink" rel="nofollow" href="<?php echo $this->item->printLink; ?>" οnclick="window.open(this.href,'printWindow','width=900,height=600,location=no,menubar=no,resizable=yes,scrollbars=yes'); return false;">
<span><?php echo JText::_('K2_PRINT'); ?></span>
</a>
</li>
<?php endif; ?>
<?php if($this->item->params->get('itemEmailButton') && !JRequest::getInt('print')): ?>
<!-- Email Button -->
<li>
<a class="itemEmailLink" rel="nofollow" href="<?php echo $this->item->emailLink; ?>" οnclick="window.open(this.href,'emailWindow','width=400,height=350,location=no,menubar=no,resizable=no,scrollbars=no'); return false;">
<span><?php echo JText::_('K2_EMAIL'); ?></span>
</a>
</li>
<?php endif; ?>
<?php if($this->item->params->get('itemSocialButton') && !is_null($this->item->params->get('socialButtonCode', NULL))): ?>
<!-- Item Social Button -->
<li>
<?php echo $this->item->params->get('socialButtonCode'); ?>
</li>
<?php endif; ?>
<?php if($this->item->params->get('itemVideoAnchor') && !empty($this->item->video)): ?>
<!-- Anchor link to item video below - if it exists -->
<li>
<a class="itemVideoLink k2Anchor" href="<?php echo $this->item->link; ?>#itemVideoAnchor"><?php echo JText::_('K2_MEDIA'); ?></a>
</li>
<?php endif; ?>
<?php if($this->item->params->get('itemImageGalleryAnchor') && !empty($this->item->gallery)): ?>
<!-- Anchor link to item image gallery below - if it exists -->
<li>
<a class="itemImageGalleryLink k2