Joomla:将职位添加到博客内容区域

Joomla:将职位添加到博客内容区域,joomla,position,blogs,Joomla,Position,Blogs,我正在尝试向工作表的内容区域添加新位置。 这就是,我希望我的博客条目如下: 职位#1 职位#2 邮政#3 新职位#1 职位#4 邮政#5 邮政#6 新职位#2 邮政#7 邮政#8 邮政#9 最终,这两个新位置将用于横幅广告 我不想在文章中插入位置,因为博客会非常动态,文章会快速向下滚动。除此之外,任何可以自动化的东西都应该是。 有人告诉我,实现这一点的聪明方法是创建博客布局覆盖。 现在,考虑到我是个新手,一只手绑在鼻子上瞎飞,我的猫是副驾驶,我开始觉得有点迷茫了。 我读了所有关于PHP和重写的书

我正在尝试向工作表的内容区域添加新位置。 这就是,我希望我的博客条目如下:

职位#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-在C:\xampp\htdocs\j303b1\templates\testa4\u 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>

调试
位置-2
位置-4
位置-5
位置-7
位置-9
位置-10
位置-11
位置-12
位置-15
位置-16
位置-17
位置-18
位置-19
位置-20
位置-21
位置-22
位置-23
位置-24
位置-25
位置-26
位置-27
新职位
3-在C:\xampp\htdocs\j303b1\templates\testa4\u 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');
?>

这在Joomla 1.5中曾经适用于我,并且可以在任何地方使用。我不会费心复制artisteer试图做的任何事情,只需导入助手并获取模块

/***************************************
* 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);
}

其实并不难,你真的确定调用了正确的文件吗?尝试输出一些调试(这些应该很容易看到),这样您就可以确定这是正确的文件,我也这么做,而且实现起来相当简单(虽然我有固定的内容,但您的内容是动态的(一个位置),但是您有loadposition插件可以从中复制。
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; ?>
<?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
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();
/***************************************
* 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);
}
/***************************************
* 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);
}