我可以在Joomla的“列出所有联系人类别”页面中显示类别中的联系人列表吗? [英] Can I show a list of contacts within category, on the 'List all contact categories' page in Joomla?
问题描述
$ b $ ol <$>
我想使用第一个选项,列表下的每个类别显示该类别中的联系人列表,以及一个链接到他们的个人资料。
我想到的最简单的方法是编辑模板覆盖文件com_contact / categories / default_items.php
我发现一个点,我希望列表出现,然后复制和粘贴代码从类别视图(生成
< ul>
<?php //添加每个类别的联系人列表
foreach($ this-> items as $ i => $ item):?>
< li>
< a href =<?php echo JRoute :: _(ContactHelperRoute :: getContactRoute($ item-> slug,$ item-> catid));?>>
<?php echo $ item-> name; ?>
< / a>
< / li>
<?php endforeach; ?>
< / ul>
但是我假设我不能复制和粘贴,因为需要额外的节点添加到$ this-> items。
目前,没有列表正在生成,只是 那么,任何人都可以指出我正确的方向,如何引用一个类别内的联系人?所有我后面的是名字和slug / URL。 UPDATE: BUMP - 有没有人有这方面的经验?或者在查看类别时能够呼叫个人联系人?它们是如何链接的? 对于 对于 So in a nutshell, you have two options for displaying Contacts in Joomla: I want to use the first option, but merge a list underneath each Category showing the list of contacts within that category, and a link to their profile. The simplest way I thought of this was to edit a template override of the file com_contact/categories/default_items.php I found a point where I want the list to appear, and then copied and pasted the code from the Category view (that generates the list of contacts). But I am assuming I can't just copy and paste, as there needs to be an extra node added to $this->items. At the moment, no list is being generated, just the So can anyone point me in the right direction as to how to reference the contacts within a category? All I'm after is the name and the slug/URL. UPDATE:
I saw this in the same file (default_items.php) and although I realise it's referring to child categories... would this be a place to start for the actual contacts within the categories? BUMP - Does anyone have any experience with this? Or being able to call individual contacts when viewing a category? How are they linked? For For
这篇关于我可以在Joomla的“列出所有联系人类别”页面中显示类别中的联系人列表吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!< ul> $ c $在
foreach
循环之外,还有趣的是,< li>
和< a>
IS正在生成..但是链接到当前页面我可能是因为 $ item-> slug
是仍然被视为类别)。
我在同一个文件(default_items.php)中看到了这个,虽然我意识到这是指子类别...这是一个地方开始的类别内的实际联系?
< (if(count($ item-> getChildren())> 0):?>
< div class =collapse fadeid =category-<?php echo $ item-> id;?>>
<?php
$ this-> items [$ item-> id] = $ item-> getChildren();
$ this-> parent = $ item;
$ this-> maxLevelcat--;
echo $ this-> loadTemplate('items');
$ this-> parent = $ item-> getParent();
$ this-> maxLevelcat ++;
?>
< / div>
<?php endif; ?>
类别视图
c $ c> default_children.php 标签< li ...
添加代码:
<?php
//获取类别模型数据
$ categoryModel = JModelLegacy :: getInstance('Category','ContactModel', array('ignore_request'=> true));
$ categoryModel-> setState('category.id',$ child-> id);
$ categoryModel-> setState('list.ordering','a.name');
$ categoryModel-> setState('list.direction','asc');
$ categoryModel-> setState('filter.published',1);
$ contacts = $ categoryModel-> getItems();
?>
自定义字段
在previus代码后添加:
JLoader :: register('FieldsHelper',JPATH_ADMINISTRATOR。'/components/com_fields/helpers/fields.php');
foreach($ contacts为$ contactItem){
$ currentContFields [] = FieldsHelper :: getFields('com_contact.contact',$ contactItem,true);
}
<ul>
<?php // Add list of contacts for each category
foreach ($this->items as $i => $item) : ?>
<li>
<a href="<?php echo JRoute::_(ContactHelperRoute::getContactRoute($item->slug, $item->catid)); ?>">
<?php echo $item->name; ?>
</a>
</li>
<?php endforeach; ?>
</ul>
<ul>
outside the foreach
loop.. but also interestingly, the <li>
and the <a>
IS being generated.. but linking to the current page I'm on (Probably because $item->slug
is still being seen as the category).<?php if (count($item->getChildren()) > 0) :?>
<div class="collapse fade" id="category-<?php echo $item->id;?>">
<?php
$this->items[$item->id] = $item->getChildren();
$this->parent = $item;
$this->maxLevelcat--;
echo $this->loadTemplate('items');
$this->parent = $item->getParent();
$this->maxLevelcat++;
?>
</div>
<?php endif; ?>
Category view
in file default_children.php
after tag <li...
add code: <?php
// Get Category Model data
$categoryModel = JModelLegacy::getInstance('Category', 'ContactModel', array('ignore_request' => true));
$categoryModel->setState('category.id', $child->id);
$categoryModel->setState('list.ordering', 'a.name');
$categoryModel->setState('list.direction', 'asc');
$categoryModel->setState('filter.published', 1);
$contacts = $categoryModel->getItems();
?>
Custom Fields
add this after previus code: JLoader::register('FieldsHelper', JPATH_ADMINISTRATOR . '/components/com_fields/helpers/fields.php');
foreach($contacts as $contactItem) {
$currentContFields[] = FieldsHelper::getFields('com_contact.contact', $contactItem, true);
}