繁体   English   中英

表达式引擎 - 类别条目帮助

[英]Expression Engine - Help with category entries

好的,我已经为客户设置了添加项目的渠道。 它的工作方式很简单:

我有一个类别页面,显示所选类别中的所有项目。

然后我有一个显示项目的 title_permalink 页面,在此页面上有 6 个来自该类别的最新相关项目,每个链接到项目/视图页面。 在此页面上,它显示该项目,并再次显示 SAME 6 个最近的相关项目。

我需要将 6 个最近的相关项目更改为 6 个以前的项目(来自类别),具体取决于选择了哪个项目? 例如,我有 20 个按输入日期排序的项目,我单击星期五 09:30 输入的数字 11。 我需要查看页面来显示之前的 6 个项目(按日期和时间),具体取决于您所在的项目页面。

我搜索了高低,但没有找到任何帮助。 我不是要别人给我答案。 我只需要指出正确的方向来解决这个问题。

我的项目(title_permalink)页面的代码是:

<div id="projectView">
{exp:channel:entries channel="project"}
{exp:imgsizer:size src="{project_image}" width="980px" height="450px"}
<img src="{sized}" width="{width}" height="{height}"/>
{/exp:imgsizer:size}
<div id="projectView_overlay"></div>
<div id="projectView_content">
    <h3>{title}</h3>
    <p class="projectView_floatLeft"><b>Client:</b> {project_client} &ndash; <b>Value:</b> £{project_value} &ndash; <b>Duration:</b> {project_duration} weeks &ndash; <b>Architect:</b> {project_architect}</p>
    <p class="projectView_floatRight" style="color:#fff; font-size: 12.5px; font-weight:bold; margin-bottom: 5px;">{categories}<a href="{path='projects/list'}" style="color:#fff;"><< Back to<br />{category_name}</a>{/categories}</p>
</div>
{/exp:channel:entries}

<br style="clear:both"/>
</div><!--END PROJECT VIEW-->

<ul id="filmStrip">
    {exp:channel:entries start_on="{entry_date format="%Y-%m-%d %H:%i"}" channel="project" limit="6" category_group="1" related_categories_mode="yes" custom_fields="yes"}
    <li>
    {exp:imgsizer:size src="{project_image}" height="68px" width="137px"}
    <a href="{title_permalink='projects/view'}"><img src="{sized}" height="{height}" width="{width}" alt=""/></a>
    {/exp:imgsizer:size}
    <a href="{title_permalink='projects/view'}"><p class="thumbTitle">{title}</p></a>
    </li>
    {/exp:channel:entries}
</ul><!--END FILM STRIP-->

谢谢你的帮助!

频道标签有一个名为 start_on=[DATE] 的参数。 我建议您从之前要提取条目的项目中获取条目日期,然后在相关条目标签中使用该日期。 请注意,您正在使用变量{exp:channel:entries}来填充另一个 channel:entries 标记,因此它始终会拉取您想要的项目 - 您没有对其进行硬编码。

{exp:channel:entries} // This tag gets your single project data
//output your project details here
{exp:channel:entries start_on="{entry_date format="%Y-%m-%d %H:%i"}" channel="project" limit="6" category_group="1" related_categories_mode="yes" custom_fields="yes"} // this tag grabs the last six projects relative to the single project being displayed
{make your links to the projects here}
{/exp:channel:entries}
{/exp:channel:entries}

您需要使用格式 YYYY-MM-DD HH:MM,如上。

丹的答案中的一个缺陷是他嵌套了两个 channel:entries 标签。 这可能导致灾难。 您需要嵌入“相关”模板。 另外,我认为您想要stop_before ,而不是start_on 试试这个修改后的代码:

<div id="projectView">
{exp:channel:entries channel="project"}
    {exp:imgsizer:size src="{project_image}" width="980px" height="450px"}
<img src="{sized}" width="{width}" height="{height}"/>
{/exp:imgsizer:size}
<div id="projectView_overlay"></div>
<div id="projectView_content">
    <h3>{title}</h3>
    <p class="projectView_floatLeft"><b>Client:</b> {project_client} &ndash; <b>Value:</b> £{project_value} &ndash; <b>Duration:</b> {project_duration} weeks &ndash; <b>Architect:</b> {project_architect}</p>
<p class="projectView_floatRight" style="color:#fff; font-size: 12.5px; font-weight:bold; margin-bottom: 5px;">{categories}<a href="{path='projects/list'}" style="color:#fff;"><< Back to<br />{category_name}</a>{/categories}</p>
</div>

<br style="clear:both"/>
</div><!--END PROJECT VIEW-->

{embed="projects/related" stop_before="{entry_date format="%Y-%m-%d %H:%i"}"}
{/exp:channel:entries}

projects/related看起来像:

{exp:channel:entries channel="project" limit="6" category_group="1" stop_before="{embed:stop_before}" related_categories_mode="yes" custom_fields="yes"}
{if count == "1"}<ul id="filmStrip">{/if}
<li>
{exp:imgsizer:size src="{project_image}" height="68px" width="137px"}
<a href="{title_permalink='projects/view'}"><img src="{sized}" height="{height}" width="{width}" alt=""/></a>
{/exp:imgsizer:size}
<a href="{title_permalink='projects/view'}"><p class="thumbTitle">{title}</p></a>
</li>
{if count == total_results}</ul>{/if}
{/exp:channel:entries}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM