ExpressionEngine:帮助w /订购反向相关条目

Mat*_*ith 7 expressionengine

我对一些反向相关条目的排序遇到了一些问题.EE只有一些限制,我正在寻找快速解决方案.您将提供任何帮助,我们将不胜感激.

我有两个渠道:注册和学生.学生有一个关系字段,将每个条目链接到注册渠道中的条目.(我需要继续使用EE关系字段.)

学生频道分配了两个类别组:成绩(组#1)和乐器(组#2).类别ID#1-6属于成绩类别.

以下代码实现了我需要它做的一半:

{exp:channel:entries channel="registrations" entry_id="{segment_4}" dynamic="no"}
<table>
{reverse_related_entries channel="students"}
{categories show="1|2"}
 <tr>
  <td><?php print $count; ?>.</td>
  <td>{title}</td>
  {embed="_includes/student_print" student_id="{entry_id}"}
 </tr>
{/categories}
{/reverse_related_entries}
</table>
<table>
{reverse_related_entries channel="students"}
{categories show="3|4"}
 <tr>
  <td><?php print $count; ?>.</td>
  <td>{title}</td>
  {embed="_includes/student_print" student_id="{entry_id}"}
 </tr>
{/categories}
{/reverse_related_entries}
</table>
<table>
{reverse_related_entries channel="students"}
{categories show="5|6"}
 <tr>
  <td><?php print $count; ?>.</td>
  <td>{title}</td>
  {embed="_includes/student_print" student_id="{entry_id}"}
 </tr>
{/categories}
{/reverse_related_entries}
</table>
{/exp:channel:entries}
Run Code Online (Sandbox Code Playgroud)

这是student_print嵌入:

{exp:channel:entries channel="students" entry_id="{embed:student_id}" dynamic="no"}
<td><font size="2">{categories show_group="2"}{category_name}{/categories}</font></td>
<td><font size="2">{categories show_group="1"}{category_name}{/categories}</font></td>
{/exp:channel:entries}
Run Code Online (Sandbox Code Playgroud)

现在 - 我需要它做的是通过仪器类别组(组#2)中类别的CUSTOM ORDER命令反向相关条目.我只是不知道如何去做我目前正在做的事情(显示三个表 - 每个表显示来自组#1中特定类别的条目)并将它们放入组#2中类别的自定义顺序.

再次 - 组#2中的类别是自定义顺序,我需要在该自定义顺序中显示相关条目.这个很重要.

有任何想法吗?这可以通过自定义查询完成吗?我真的很感谢代码示例 - 如果可能的话.这正在扩展我的EE和SQL chops.

非常感谢你的时间.

Der*_*gue 1

老实说,我的第一印象是这是错误的构建方式。太复杂了。但从外面说出来总是很容易,对吧?:)

其次,我不确定您需要这个注册频道的目的是什么,因为您似乎没有使用其中的任何数据(除非您为了清楚起见删除了一些代码)?

但无论如何,这里有一些未经测试的代码。要点是,您只能使用channel:categories标签按类别排序,然后将其传递{category_id}给新channel:entries标签。如果我们将所有entry_ids的列表传递给其中的每个标签,它应该过滤掉所有不属于{category_id}您传递的特定内容。

{exp:channel:entries channel="registrations" entry_id="{segment_4}" dynamic="no"}
    {embed="_includes/student_print" entry_ids="{reverse_related_entries channel="students" backspace="1"}{entry_id}|{/reverse_related_entries}"}
{/exp:channel:entries}
Run Code Online (Sandbox Code Playgroud)

然后你的嵌入看起来像这样:

{exp:channel:categories channel="students" style="linear" show="1|2"}
{if count == "1"}<table>{/if}
    {exp:channel:entries channel="students" entry_id="{embed:entry_ids}" category="{category_id}" dynamic="no"}
    <tr>
        <td><?php print $count; ?>.</td>
        <td>{title}</td>
        <td><font size="2">{categories show_group="2"}{category_name}{/categories}</font></td>
        <td><font size="2">{categories show_group="1"}{category_name}{/categories}</font></td>      
    </tr>
    {/exp:channel:entries}
{if count == total_results}</table>{/if}
{/exp:channel:categories}

{exp:channel:categories channel="students" style="linear" show="3|4"}
{if count == "1"}<table>{/if}
    {exp:channel:entries channel="students" entry_id="{embed:entry_ids}" category="{category_id}" dynamic="no"}
    <tr>
        <td><?php print $count; ?>.</td>
        <td>{title}</td>
        <td><font size="2">{categories show_group="2"}{category_name}{/categories}</font></td>
        <td><font size="2">{categories show_group="1"}{category_name}{/categories}</font></td>      
    </tr>
    {/exp:channel:entries}
{if count == total_results}</table>{/if}
{/exp:channel:categories}

{exp:channel:categories channel="students" style="linear" show="5|6"}
{if count == "1"}<table>{/if}
    {exp:channel:entries channel="students" entry_id="{embed:entry_ids}" category="{category_id}" dynamic="no"}
    <tr>
        <td><?php print $count; ?>.</td>
        <td>{title}</td>
        <td><font size="2">{categories show_group="2"}{category_name}{/categories}</font></td>
        <td><font size="2">{categories show_group="1"}{category_name}{/categories}</font></td>      
    </tr>
    {/exp:channel:entries}
{if count == total_results}</table>{/if}
{/exp:channel:categories}
Run Code Online (Sandbox Code Playgroud)

我不知道$count你的 PHP 变量是什么,但可能需要修改,因为它现在在嵌入中。

让我知道这是否有结果?