打印具有相同字段值的内容的频道内容
使用表达式引擎,我需要在职位页面上显示其他可用职位。工作要么是合同性的,要么是永久性的,在工作页面上我只需要显示相同类型的其他工作。
以下内容打印所有其他职位及其类型:
{exp:channel:entries channel="jobs" dynamic="no"}
<p>{title}
{job_type}</p>
{/exp:channel:entries}
这将仅打印所有联系职位:
{exp:channel:entries channel="jobs" search:job_type="Contract" dynamic="no"}
<p>{title}
{job_type}</p>
{/exp:channel:entries}
因此,我尝试使用 {job_type} 字段来优化搜索结果。但是,使用以下内容我根本没有得到任何结果:
{exp:channel:entries channel="jobs" search:job_type="{job_type}" dynamic="no"}
<p>{title}
{job_type}</p>
{/exp:channel:entries}
有人说我需要使用 PHP 标签,所以我尝试了以下操作,但它返回了所有结果:
{exp:channel:entries channel="jobs" search:job_type="<?=$this->EE->input->get('job_type')?>" dynamic="no"}
<p>{title}
{job_type}</p>
{/exp:channel:entries}
我怎样才能实现我需要的?我是 EE 新手,但我认为这会是一些标准的东西?
请注意,URL 结构不允许我使用 url 段来过滤结果。 谢谢
With Expression Engine I need to show the other available jobs when on a jobs page. Jobs are either contract or permanent, and on the jobs page I need to only show other jobs of the same type.
The following prints all the other jobs as well as their type:
{exp:channel:entries channel="jobs" dynamic="no"}
<p>{title}
{job_type}</p>
{/exp:channel:entries}
This would print all contact jobs only:
{exp:channel:entries channel="jobs" search:job_type="Contract" dynamic="no"}
<p>{title}
{job_type}</p>
{/exp:channel:entries}
So, I tried using the {job_type} field to refine the search results. However with the following I get no results at all:
{exp:channel:entries channel="jobs" search:job_type="{job_type}" dynamic="no"}
<p>{title}
{job_type}</p>
{/exp:channel:entries}
Someone said I needed to use PHP tags, so I tried the following, but it returns all the results:
{exp:channel:entries channel="jobs" search:job_type="<?=$this->EE->input->get('job_type')?>" dynamic="no"}
<p>{title}
{job_type}</p>
{/exp:channel:entries}
How can I achieve what I need? Im new to EE but I would have thought this would be somewhat standard stuff?
Note, the URL structure doesn't allow me to use url segments to filter results.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不能嵌套
{exp:channel:entries}
标记,因为这会导致变量冲突。为此,您需要使用嵌入模板,并传递{该模板的 job_type}
值。因此,在您的主
{exp:channel:entries}
循环中:那么您的 embeds/job_type 模板如下所示:
You can't nest
{exp:channel:entries}
tags, as it leads to variable collisions. You'll need to use an embedded template for this, and pass the{job_type}
value to that template.So within your main
{exp:channel:entries}
loop:Then your embeds/job_type template looks like this: