我试图在工作表的内容区域中添加新的位置。这是,我希望我的博客条目是这样的:
1员额#2员额#3新职位#1员额#4员额#5员额#6新职位#2员额#7员额#8员额#9
最终,这两个新职位将被用于横幅广告。
我不想在文章中插入位置,因为博客将非常动态,文章将快速向下滚动。另外,任何可以被自动化的东西,都应该。我被告知,聪明的方法是创建一个博客布局覆盖。现在,考虑到我是个新手,一只手绑在我的鼻子上,我的猫作为副驾驶,我开始感到有点迷茫。我确实阅读了所有关于PHP和重写的内容,但这似乎还不够。我使用Artisteer创建模板,这是非常基本的,没有任何花哨的东西,任何类型,只是基本的造型。我使用的模板叫做"testa4_50“(是的.我在50版的吸盘.陡峭的学习曲线。不要让我开始.)为了测试目的,我在Windoze XP上使用Xampp作为本地主机。我的Joomla实现是3.0.3,Artisteer似乎充分利用了重写,所以我认为应该没有那么难做。大错..。
我尝试的第一件事是,看看我是否可以在主页的正文中插入一个新的位置,以尝试理解代码。
我所采取的步骤:
1-在templateDetails.xml 2中找到C:\xampp\htdocs\j303b1\templates\testa4_50\ 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-在index.php 4中定位C:\xampp\htdocs\j303b1\templates\testa4_50\ 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-测试=失败(该位置在主页中没有出现)
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();发布于 2014-02-01 04:31:43
在Joomla1.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);
}https://stackoverflow.com/questions/16133951
复制相似问题