2011-07-06 38 views
1

好的,我已经建立了客户端添加项目的渠道。它的工作方式很简单:表达式引擎 - 帮助类别条目

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

然后我有一个显示项目的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--> 

感谢您的帮助!

回答

0

丹的答案中的一个缺陷是他嵌套两个通道:条目标记。这可能会导致灾难。您需要嵌入“相关”模板。另外,我认为你想要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} 
+0

工程就像一个魅力!我不能够感谢你。非常感谢Dan也努力帮助。我可以问,为什么stop_before?我正确地说,通过使用stop_before =“{entry_date format =”%Y-%m-%d%H:%i“}它抓住当前项目日期之前的所有项目,然后停在我们所在的那个项目目前在? –

+0

你在这个假设中是正确的。因为默认的“orderby”是“date”,而默认的“sort”是“desc”,所以它从“stop_before”日期*倒退*,这正是你正在寻找。 –

1

通道标签有一个名为start_on = [DATE]的参数。我建议你从之前想要拉入条目的项目中获取入口日期,然后在相关条目标签中使用该日期。请注意,您正在使用变量{exp: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,如上所述。

+0

嗨感谢您的帮助,但作为,我不知道他们要什么项目,点击到不能不幸工作。我需要它将以前的6个项目取决于他们点击哪个项目。 –

+0

@ John-Stant - 将该代码放在项目页面上,而不是包含项目列表的页面。 – Dan

+0

对不起,您要查看的页面?它是:项目类别页面列表或实际项目title_permalink页面?我在title_permalink页面上试了一下,什么也没有发生。 –