最新条目链接问题 - 表达式引擎
可能的重复:
表达式引擎 - 表达式引擎 ul 中静态代码的帮助< /a>
我在链接到 title_permalink“查看”页面的最新条目时遇到问题。我已在此页面上创建了一个链接,但需要它链接到该特定类别中的最新条目。这是我的代码:
{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-test/view'}"><img src="{sized}" height="{height}" width="{width}" alt=""/></a>
{/exp:imgsizer:size}
<a href="{title_permalink='projects-test/view'}"><p class="thumbTitle">{title}</p></a>
</li>
{if total_results <= '5' AND total_results == count}
<li>
<a href="{path='projects-test/view'}/{first_entry_id}"><img src="../../../images/backtostart.jpg" height="68px" width="137px" alt=""/></a>
<a href="{path='projects-test/view'}/{first_entry_id}"><p class="thumbTitle">Back to start</p></a>
</li>
{/if}
{if count == total_results}</ul>{/if}
{/exp:channel:entries}
我本以为这很容易,但事实似乎并非如此!我的代码是 if Total_results 条件内的代码。
我已经尝试了一切,基本上我有很多项目,一旦项目结束,就会有一个按钮显示“返回项目开始”。可以这么说,我需要它循环回到开头。
编辑: 这是我添加下面建议的解决方案后的代码。
{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-test/view'}"><img src="{sized}" height="{height}" width="{width}" alt=""/></a>
{/exp:imgsizer:size}
<a href="{title_permalink='projects-test/view'}"><p class="thumbTitle">{title}</p></a>
</li>
{if total_results <= '5' AND total_results == count}
{categories show_group="1" limit="1"}
{exp:query sql="SELECT t.entry_id as first_entry_id FROM exp_channel_titles t LEFT JOIN exp_category_posts c ON t.entry_id = c.entry_id WHERE c.cat_id = {category_id} AND t.status != 'closed' ORDER BY t.entry_date DESC LIMIT 1"}
<li>
<a href="{path='projects-test/view'}/{first_entry_id}"><img src="../../../images/backtostart.jpg" height="68px" width="137px" alt=""/></a>
<a href="{path='projects-test/view'}/{first_entry_id}"><p class="thumbTitle">Back to start</p></a>
</li>
{/exp:query}
{/categories}
{/if}
{if count == total_results}</ul>{/if}
{/exp:channel:entries}
以下是该页面的链接:
Possible Duplicate:
Expression Engine - Help with static code inside expression engine ul
I am having problems linking to a latest entry from a title_permalink "view" page. I have created a link on this page but need it to link to the latest entry in that specific category. This is my code:
{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-test/view'}"><img src="{sized}" height="{height}" width="{width}" alt=""/></a>
{/exp:imgsizer:size}
<a href="{title_permalink='projects-test/view'}"><p class="thumbTitle">{title}</p></a>
</li>
{if total_results <= '5' AND total_results == count}
<li>
<a href="{path='projects-test/view'}/{first_entry_id}"><img src="../../../images/backtostart.jpg" height="68px" width="137px" alt=""/></a>
<a href="{path='projects-test/view'}/{first_entry_id}"><p class="thumbTitle">Back to start</p></a>
</li>
{/if}
{if count == total_results}</ul>{/if}
{/exp:channel:entries}
I would've thought this would be easy enough but it seems not! My code is the code inside the if total_results conditional.
I've tried everything, basically I have numerous projects, and once the end of projects is reached, there is a button that says "Back to start of projects". I need this to go back to the beginning in a loop so to speak.
EDIT:
This is my code after adding the proposed solution below.
{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-test/view'}"><img src="{sized}" height="{height}" width="{width}" alt=""/></a>
{/exp:imgsizer:size}
<a href="{title_permalink='projects-test/view'}"><p class="thumbTitle">{title}</p></a>
</li>
{if total_results <= '5' AND total_results == count}
{categories show_group="1" limit="1"}
{exp:query sql="SELECT t.entry_id as first_entry_id FROM exp_channel_titles t LEFT JOIN exp_category_posts c ON t.entry_id = c.entry_id WHERE c.cat_id = {category_id} AND t.status != 'closed' ORDER BY t.entry_date DESC LIMIT 1"}
<li>
<a href="{path='projects-test/view'}/{first_entry_id}"><img src="../../../images/backtostart.jpg" height="68px" width="137px" alt=""/></a>
<a href="{path='projects-test/view'}/{first_entry_id}"><p class="thumbTitle">Back to start</p></a>
</li>
{/exp:query}
{/categories}
{/if}
{if count == total_results}</ul>{/if}
{/exp:channel:entries}
Here is the link to the page:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的,我对 上一个相关问题的回答存在问题 的问题是,使用 lated_categories_mode 参数时,
{categories}
不可用。但我意识到查询所需的只是类别组的group_id
。因此,请尝试以下操作:更新:或者,如果您能够通过嵌入传递主条目的
{category_id}
,您可以执行以下操作:OK, the issue with my answer to the previous related question was that when using the related_categories_mode parameter,
{categories}
isn't available. But I realized that all you need for the query is thegroup_id
for the category group anyway. So, try this:UPDATE: or, if you're able to pass the main entry's
{category_id}
via an embed, you can do this: