我正在尝试将新位置添加到工作表的内容区域。也就是说,我希望我的博客条目是这样的:
发布#1 发布#2 发布#3 新职位#1 发布#4 发布#5 发布#6 新职位#2 发布#7 发布#8 发布#9
最终,这两个新位置将用于横幅广告。
我不想在文章中插入职位,因为博客会非常动态,文章会快速向下滚动。此外,任何可以自动化的东西都应该。有人建议我这样做的聪明方法是创建一个博客布局覆盖。现在,考虑到我是一个新手,一只手绑在鼻子上,我的猫作为副驾驶,我正在盲目飞行,我开始感到有点失落。我确实阅读了有关 PHP 和覆盖的所有内容,但这似乎还不够。我正在使用 Artisteer 创建模板,非常基本的,没有任何花哨的东西,只是基本的造型。我正在使用的模板称为“testa4_50”(是的……我正在使用 50 版的傻瓜……陡峭的学习曲线……不要让我开始……)。我在 Windoze XP 上使用 Xampp 作为 localhost 进行测试。我的 Joomla 实现是 3.0.3 Artisteer 似乎大量使用了覆盖,所以我认为应该不难做到......大错特错......
我尝试的第一件事是查看是否可以在主页正文的某处插入一个新位置以尝试理解代码。
我采取的步骤:
1 - 在 C:\xampp\htdocs\j303b1\templates\testa4_50\ 中找到 templateDetails.xml 2 - 找到列表并添加我的“新位置”;看起来像:
<positions>
<position>debug</position>
<position>position-2</position>
<position>position-4</position>
<position>position-5</position>
<position>position-7</position>
<position>position-9</position>
<position>position-10</position>
<position>position-11</position>
<position>position-12</position>
<position>position-15</position>
<position>position-16</position>
<position>position-17</position>
<position>position-18</position>
<position>position-19</position>
<position>position-20</position>
<position>position-21</position>
<position>position-22</position>
<position>position-23</position>
<position>position-24</position>
<position>position-25</position>
<position>position-26</position>
<position>position-27</position>
<position>position-new</position>
</positions>
3 - 在 C:\xampp\htdocs\j303b1\templates\testa4_50\ 中找到 index.php 4 - 在位置块中找到正确的位置:
<?php
echo $view->position('position-19', 'art-nostyle');
if ($view->containsModules('position-2'))
echo artxPost($view->position('position-2'));
echo $view->positions(array('position-20' => 50, 'position-21' => 50), 'art-article');
echo $view->position('position-12', 'art-nostyle');
echo artxPost(array('content' => '<jdoc:include type="message" />', 'classes' => ' art-messages'));
echo '<jdoc:include type="component" />';
echo $view->position('position-22', 'art-nostyle');
echo $view->positions(array('position-23' => 50, 'position-24' => 50), 'art-article');
echo $view->position('position-25', 'art-nostyle');
?>
5 - 添加我的新位置,复制现有代码:
<?php
echo $view->position('position-19', 'art-nostyle');
if ($view->containsModules('position-2'))
echo artxPost($view->position('position-2'));
echo $view->positions(array('position-20' => 50, 'position-21' => 50), 'art-article');
echo $view->position('position-12', 'art-nostyle');
echo $view->position('position-new', 'art-nostyle');
echo artxPost(array('content' => '<jdoc:include type="message" />', 'classes' => ' art-messages'));
echo '<jdoc:include type="component" />';
echo $view->position('position-22', 'art-nostyle');
echo $view->positions(array('position-23' => 50, 'position-24' => 50), 'art-article');
echo $view->position('position-25', 'art-nostyle');
?>
6 - 检查 Joomla / Preview 7 中的位置 - 一切正常。
所以,我想出了代码“echo $view->position('position-new', 'art-nostyle');” 也应该在其他任何地方工作。
现在,我尝试在博客的任何位置创建一个新职位。
我采取的步骤:
1 - 在 \Dell-pc\xampp\htdocs\J303b1\templates\testa4_50\html\com_content\category 中找到 blog.php(完整文件附在这篇文章中)
2 - 在文件中找到正确的位置
echo artxPost(array('header-text' => $view->pageHeading, 'content' => ob_get_clean()));
?>
<?php $leadingcount=0 ; ?>
<?php if (!empty($this->lead_items)) : ?>
<div class="items-leading">
<?php foreach ($this->lead_items as &$item) : ?>
<div class="leading-<?php echo $leadingcount; ?><?php echo $item->state == 0 ? ' system-unpublished' : null; ?>">
<?php
$this->item = &$item;
echo $this->loadTemplate('item');
?>
</div>
<?php $leadingcount++; ?>
<?php endforeach; ?>
</div>
<?php endif; ?>
3 - 插入代码:
echo artxPost(array('header-text' => $view->pageHeading, 'content' => ob_get_clean()));
?>
<?php echo $view->position('position-new', 'art-nostyle') ?>
<?php $leadingcount=0 ; ?>
<?php if (!empty($this->lead_items)) : ?>
<div class="items-leading">
<?php foreach ($this->lead_items as &$item) : ?>
<div class="leading-<?php echo $leadingcount; ?><?php echo $item->state == 0 ? ' system-unpublished' : null; ?>">
<?php
$this->item = &$item;
echo $this->loadTemplate('item');
echo $view->position('position-new', 'art-nostyle');
?>
</div>
<?php $leadingcount++; ?>
<?php endforeach; ?>
</div>
<?php endif; ?>
4 - Test = FAIL(该位置未出现在主页的任何位置)
5 - 将代码更改为
并插入相同的位置。测试 = 失败。
============================ 在这一点上,我被难住了。我无法在内容区域的任何位置插入新位置。最初我想在上面的循环中插入这段代码(看看我是否可以在第三个帖子之后插入至少一个新位置):
<?php $leadingcount=0 ; ?>
<?php if (!empty($this->lead_items)) : ?>
<div class="items-leading">
<?php foreach ($this->lead_items as &$item) : ?>
<div class="leading-<?php echo $leadingcount; ?><?php echo $item->state == 0 ? ' system-unpublished' : null; ?>">
<?php
$this->item = &$item;
echo $this->loadTemplate('item');
echo $view->position('position-new', 'art-nostyle');
If ($leadingcount==3) echo $view->position('position-new', 'art-nostyle');
?>
</div>
<?php $leadingcount++; ?>
<?php endforeach; ?>
</div>
<?php endif; ?>
但是,当然,它不起作用。
任何建议/意见将不胜感激!
博客.php 文件
<?php
defined('_JEXEC') or die;
require_once dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR . 'functions.php';
if ('artisteer' == JFactory::getApplication()->getTemplate(true)->params->get('blogLayoutType')) {
require 'art_blog.php';
return;
}
Artx::load("Artx_Content");
$view = new ArtxContent($this, $this->params);
echo $view->beginPageContainer('blog');
ob_start();
if ($this->params->get('show_category_title', 1) || strlen($this->params->get('page_subheading'))) {
echo '<h2>';
echo $this->escape($this->params->get('page_subheading'));
if ($this->params->get('show_category_title') && strlen($this->category->title))
echo '<span class="subheading-category">' . $this->category->title . '</span>';
echo '</h2>';
}
if ($this->params->def('show_description', 1) || $this->params->def('show_description_image', 1)) {
echo '<div class="category-desc">';
if ($this->params->get('show_description_image') && $this->category->getParams()->get('image'))
echo '<img src="' . $this->category->getParams()->get('image') . '" alt="" />';
if ($this->params->get('show_description') && $this->category->description)
echo JHtml::_('content.prepare', $this->category->description, '', 'com_content.category');
echo '</div>';
}
echo artxPost(array('header-text' => $view->pageHeading, 'content' => ob_get_clean()));
?>
<?php echo $view->position('position-new', 'xhtml') ?>
<?php $leadingcount=0 ; ?>
<?php if (!empty($this->lead_items)) : ?>
<div class="items-leading">
<?php foreach ($this->lead_items as &$item) : ?>
<div class="leading-<?php echo $leadingcount; ?><?php echo $item->state == 0 ? ' system-unpublished' : null; ?>">
<?php
$this->item = &$item;
echo $this->loadTemplate('item');
echo $view->position('position-new', 'art-nostyle');
?>
</div>
<?php $leadingcount++; ?>
<?php endforeach; ?>
</div>
<?php endif; ?>
<?php
$introcount = (count($this->intro_items));
$counter = 0;
?>
<?php if (!empty($this->intro_items)) : ?>
<?php foreach ($this->intro_items as $key => &$item) : ?>
<?php
$key= ($key-$leadingcount)+1;
$rowcount=( ((int)$key-1) % (int) $this->columns) +1;
$row = $counter / $this->columns ;
if ($rowcount==1) : ?>
<div class="items-row cols-<?php echo (int) $this->columns;?> <?php echo 'row-'.$row ; ?>">
<?php endif; ?>
<div class="item column-<?php echo $rowcount;?><?php echo $item->state == 0 ? ' system-unpublished' : null; ?>">
<?php
$this->item = &$item;
echo $this->loadTemplate('item');
?>
</div>
<?php $counter++; ?>
<?php if (($rowcount == $this->columns) or ($counter ==$introcount)): ?>
<span class="row-separator"></span>
</div>
<?php endif; ?>
<?php endforeach; ?>
<?php endif; ?>
<?php
if (!empty($this->link_items)) {
ob_start();
echo '<div class="items-more">' . $this->loadTemplate('links') . '</div>';
echo artxPost(ob_get_clean());
}
?>
<?php if (!empty($this->children[$this->category->id])&& $this->maxLevel != 0) : ?>
<?php ob_start(); ?>
<div class="cat-children">
<h3><?php echo JTEXT::_('JGLOBAL_SUBCATEGORIES'); ?></h3>
<?php echo $this->loadTemplate('children'); ?>
</div>
<?php echo artxPost(ob_get_clean()); ?>
<?php endif; ?>
<?php
if (($this->params->def('show_pagination', 1) == 1 || $this->params->get('show_pagination') == 2)
&& $this->pagination->get('pages.total') > 1)
{
ob_start();
echo '<div class="pagination">';
if ($this->params->def('show_pagination_results', 1))
echo '<p class="counter">' . $this->pagination->getPagesCounter() . '</p>';
echo $this->pagination->getPagesLinks();
echo '</div>';
echo ob_get_clean();
}
echo $view->endPageContainer();