表达式引擎-帮助表达式引擎ul中的静态代码 [英] Expression Engine - Help with static code inside expression engine ul

查看:65
本文介绍了表达式引擎-帮助表达式引擎ul中的静态代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我设法对最后一个li问题进行了排序,但是现在似乎无法将我的最后一个列表项链接回特定类别的最新条目。有什么想法吗?

I've managed to sort the last li issue, but can't seem to now link my last list item back to the latest entry in the specific category. Any ideas?

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


推荐答案

一个问题是您使用的是 {count} {total_results} 变量不起作用。

One issue is that you're using the {count} and {total_results} variables outside of the channel:entries loop, which won't work.

在这里,您可以通过这种方式来限制后退链接的显示,并且还可以链接到该类别中的第一个条目(通过第一个,我假设您的意思是最新):

Here's how you can limit the display of the "back" link in this manner, and also link to the first entry in that category (by "first" I assume you mean "newest"):

{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 count == total_results}
    {if count == "5"}
    {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 = 'open' 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}
</ul>{/if}
{/exp:channel:entries}

我还没有测试过,所以让我知道它是否合适。

I haven't tested this, so let me know if it throws a fit.

更新:尝试使第一项查询生效的事情:

UPDATE: Things to try to get the "first entry" query to work:


  • parse = inward 添加到exp:query标记。

  • 尝试直接运行SQL查询通过EE控制面板中的SQL管理器(将category_id替换为{category_id}变量),看看是否返回正确的entry_id。

  • 请记住,此代码假定每个项目都将

  • Add parse="inward" to the exp:query tag.
  • Try running the SQL query directly via the SQL Manager within the EE control panel (substituting a category_id for the {category_id} variable), and see if that returns the correct entry_id.
  • Remember that this code assumes that each project will only have one category assigned to it in that category group.

嵌套的 {if} 应该上面使用的$ c>语句可以工作-与使用更新原始帖子的高级语句相比,最好使用它,因为它会使查询语句每次运行。

The nested {if} statement I used above should work - and it's better to use that than the advanced one you updated your original post with, as it will cause the query statement to run every time.

这篇关于表达式引擎-帮助表达式引擎ul中的静态代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆