我正在尝试将新位置添加到工作表的“内容”区域。 这是,我希望我的博客条目是这样的:
发布#1 发布#2 发布#3 新职位#1 发布#4 发布#5 发布#6 新职位#2 发布#7 发布#8 发布#9
最终这两个新职位将用于横幅广告。
我不想在文章中插入位置,因为博客会非常动态,文章会快速向下滚动。此外,任何可以自动化的东西都应该。 我被告知,这样做的聪明方法是创建一个Blog Layout覆盖。 现在,考虑到我是一个新手,我一只手绑在我的鼻子和我的猫作为副驾驶,我开始觉得有点失落。 我确实阅读了关于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 - 找到列表并添加我的“position-new”;看起来像是:
<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-&gt; 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 - 测试=失败(位置不会出现在主页的任何位置)
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; ?>
但当然,它不起作用。
任何建议/建议都会受到高度赞赏!
Blog.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();
答案 0 :(得分:0)
这曾经在Joomla 1.5中为我工作,可以在任何地方使用。我不打算复制艺术家试图做的任何事情,只需导入帮助程序并获取模块。
/***************************************
* Load module in a view file*/
// import the module helper
jimport('joomla.application.module.helper');
// this is where you want to load your module position
$modules = JModuleHelper::getModules('moduleposition');
foreach($modules as $module)
{
echo JModuleHelper::renderModule($module);
}
对于joomla 3,我认为它更像是
/***************************************
* Load module in a view file*/
// import the module helper
$document = JFactory::getDocument();
$renderer = $document->loadRenderer('module');
// this is where you want to load your module position
$modules = JModuleHelper::getModules('moduleposition');
foreach($modules as $module)
{
echo $renderer->render($module);
}