geo*_*310 5 php codeigniter expressionengine
我创建了一个名为信用卡的频道.所以我创建了一个名为信用卡的模板组,其索引循环遍历所有信用卡并输出.这方面工作正常,这是我在credit-cards.group文件夹中的index.html文件的代码:
{exp:channel:categories category_group="1" style="linear" dynamic="no"}
<div class="card-list tab" id="{category_url_title}">
<h2 class="category-title">{category_name} Credit Cards</h2>
<div class="cards">
{exp:channel:entries channel="credit_cards" category="{category_id}" dynamic="no"}
<article>
<h4><a href="{url_title_path='credit-cards'}">{title}</a><span class="web-exclusive">MBNA Website Exclusive</span></h4>
<ul>
<li class="col-img">
<a href="{url_title_path='credit-cards'}"><img width="116" height="84" alt="MBNA Platinum Credit Card" src="../lib-ui/img/cards/core/core_116x84/mbna_platinum_card_116x84.png"></a>
</li>
<li class="col-bt">{balance_transfer_rate}</li>
<li class="col-purchases">{purchases_rate}</li>
<li class="col-features">{key_features}</li>
<li class="col-apply">
<a rel="blank" class="btn btn-success" href="{apply_url}">
Apply Now<span class="hide"> for the {title}</span>
</a>
<a class="cta" href="{url_title_path='credit-cards'}">
Learn more<span class="hide"> about the {title}</span>
</a>
<label class="mbna-credit-card checkbox" for="compare_1">
<span tabindex="0">
<input type="checkbox" value="mbna-credit-card" id="compare_1">
</span>
<span class="hide"> Add the {title} to </span>Compare
</label>
</li>
</ul>
<p class="rep-ex">{representative_example}</p>
</article>
{/exp:channel:entries}
</div>
</div>
{/exp:channel:categories}
Run Code Online (Sandbox Code Playgroud)
所以我的问题是这个.假设我有一张名为签证信用卡的信用卡,正在生成的网址是/信用卡/签证信用卡.当我点击此链接虽然我只是再次获取我的索引页面.我在我的组中创建了另一个名为single.html的模板文件,其中包含输出单个信用卡的代码.这看起来像这样:
<h1>Credit Card Page</h1>
{exp:channel:entries channel="credit_cards" limit="1"}
{if no_results}
{redirect="404"}
{/if}
Run Code Online (Sandbox Code Playgroud)
那么如何让它使用这个模板文件代替单个条目呢?
小智 10
这实际上是一个非常容易支持的问题.您所发生的是您的代码第5行无法判断是否应该限制条目信息.有了dynamic='no',你说过"EE,你不需要在这里使用URL来找出限制它的条目"
我的建议是以下代码:
{if segment_2 == ""}
{exp:channel:categories category_group="1" style="linear" dynamic="no"}
<div class="card-list tab" id="{category_url_title}">
<h2 class="category-title">{category_name} Credit Cards</h2>
<div class="cards">
{exp:channel:entries channel="credit_cards" category="{category_id}" dynamic="no" disable="category_fields|member_data|pagination|trackbacks"}
<article>
<h4><a href="{url_title_path='credit-cards'}">{title}</a><span class="web-exclusive">MBNA Website Exclusive</span></h4>
<ul>
<li class="col-img">
<a href="{url_title_path='credit-cards'}"><img width="116" height="84" alt="MBNA Platinum Credit Card" src="../lib-ui/img/cards/core/core_116x84/mbna_platinum_card_116x84.png"></a>
</li>
<li class="col-bt">{balance_transfer_rate}</li>
<li class="col-purchases">{purchases_rate}</li>
<li class="col-features">{key_features}</li>
<li class="col-apply">
<a rel="blank" class="btn btn-success" href="{apply_url}">
Apply Now<span class="hide"> for the {title}</span>
</a>
<a class="cta" href="{url_title_path='credit-cards'}">
Learn more<span class="hide"> about the {title}</span>
</a>
<label class="mbna-credit-card checkbox" for="compare_1">
<span tabindex="0">
<input type="checkbox" value="mbna-credit-card" id="compare_1">
</span>
<span class="hide"> Add the {title} to </span>Compare
</label>
</li>
</ul>
<p class="rep-ex">{representative_example}</p>
</article>
{/exp:channel:entries}
</div>
</div>
{/exp:channel:categories}
{/if}
{if segment_2}
{exp:channel:entries channel="credit_cards" limit="1" disable="category_fields|member_data|pagination|trackbacks"}
<article>
<h4><a href="{url_title_path='credit-cards'}">{title}</a><span class="web-exclusive">MBNA Website Exclusive</span></h4>
<ul>
<li class="col-img">
<a href="{url_title_path='credit-cards'}"><img width="116" height="84" alt="MBNA Platinum Credit Card" src="../lib-ui/img/cards/core/core_116x84/mbna_platinum_card_116x84.png"></a>
</li>
<li class="col-bt">{balance_transfer_rate}</li>
<li class="col-purchases">{purchases_rate}</li>
<li class="col-features">{key_features}</li>
<li class="col-apply">
<a rel="blank" class="btn btn-success" href="{apply_url}">
Apply Now<span class="hide"> for the {title}</span>
</a>
<a class="cta" href="{url_title_path='credit-cards'}">
Learn more<span class="hide"> about the {title}</span>
</a>
<label class="mbna-credit-card checkbox" for="compare_1">
<span tabindex="0">
<input type="checkbox" value="mbna-credit-card" id="compare_1">
</span>
<span class="hide"> Add the {title} to </span>Compare
</label>
</li>
</ul>
<p class="rep-ex">{representative_example}</p>
</article>
{/exp:channel:entries}
{/if}
Run Code Online (Sandbox Code Playgroud)
请注意,这不是100%准确,因为我删除了您的exp:channel:categories标记,但这应该会得到一个结果,根据您指定的缩短的URL进行限制.
那么如何让它使用这个模板文件代替单个条目呢?
代替:
{url_title_path='credit-cards'}
Run Code Online (Sandbox Code Playgroud)
使用
{title_permalink="credit-cards/single"}
Run Code Online (Sandbox Code Playgroud)
有两种主要方法可以使用模板'credit-cards/single'作为VISA信用卡类别条目.
第一选择
'信用卡/索引'模板将具有:
{if segment_2 != ""}
{embed="credit-cards/single" entry_id="{entry_id}"}
{/if}
Run Code Online (Sandbox Code Playgroud)
'信用卡/单一'模板将具有:
<h1>Credit Card Page</h1>
{exp:channel:entries channel="credit_cards" limit="1" entry_id="{embed:entry_id}"}
{if no_results}
{redirect="404"}
{/if}
... your code ...
{/exp:channel:entries}
Run Code Online (Sandbox Code Playgroud)
第二选择
将"信用卡/单身"重命名为"信用卡/公司"(或更多与SEO相关的内容)并将其用作默认的EE方式.
'信用卡/索引'模板将保持不变.
'信用卡/公司'模板将具有:
<h1>Credit Card Page</h1>
{exp:channel:entries channel="credit_cards" limit="1" entry_id="{entry_id}"}
{if no_results}
{redirect="404"}
{/if}
... your code ...
{/exp:channel:entries}
Run Code Online (Sandbox Code Playgroud)
在第二个选项中,网址为site.com/credit-cards/company/visa-credit-card
我希望有所帮助.如果我误解了什么,请告诉我.
| 归档时间: |
|
| 查看次数: |
1703 次 |
| 最近记录: |