开发者

Expression Engine - Help with category entries

OK, I have set up channel for the client to add projects. The way it works is simple:

I have a category page that displays all of the projects from the chosen category.

I then have a title_permalink page that displays a project, on this page there are 6 most recent related projects that are from that category, each linking to a projects/view page. On this page it displays the project and again, the SAME 6 most recent related projects.

I need to change the 6 recent related projects to be 6 PREVIOUS projects (from the category) dependant on which project has been chosen? For example, I have 20 projects sorted by date entered, I click on number 11 which was entered on Friday at 09:30. I need the view page to display the PREVIOUS 6 projects (by date&time) dependant on which project page you are on.

I have searched high and low but haven't found any help. I'm not asking someone to give me the answer. I just need pointed in the right direction as to the right solution for this.

The code for my project (title_permalink) page is:

<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-->

Thanks for any help!


There is a parameter for the channels tag called start_on=[DATE]. I suggest you grab the entry date from the project you want to pull entries before, then use that date in your related entry tag. Note, you are using a variable {exp:channel:entries} to populate another channel:entries tag so it will always pull the projects you want - you are not hardcoding it.

{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}

You need to use the format YYYY-MM-DD HH:MM, as above.


The one flaw in Dan's answer is that he's nesting two channel:entries tags. That can lead to disaster. You need to embed the "related" template. Also, I think you want stop_before, not start_on. Try this modified code:

<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}

And projects/related looks like:

{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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜