I have created a channel called credit cards. So I have created a template group called credit-cards with an index which loops through all the credit cards and output them. This aspect works fine, here is my code for the index.html file inside credit-cards.group folder:
{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>{title}<span class="web-exclusive">MBNA Website Exclusive</span></h4>
<ul>
<li class="col-img">
<img width="116" height="84" alt="MBNA Platinum Credit Card" src="../lib-ui/img/cards/core/core_116x84/mbna_platinum_card_116x84.png">
</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}
So my question is this. Say I have a credit card called visa credit card, the url that is being generated for it is /credit-cards/visa-credit-card. When I click this link though I just get my index page again. I have created another template file inside my group called single.html that has the code to output a single credit card. This looks like so:
<h1>Credit Card Page</h1>
{exp:channel:entries channel="credit_cards" limit="1"}
{if no_results}
{redirect="404"}
{/if}
So how do I get it to use this template file instead for a single entry?
This is actually a pretty easy to shore up issue. What you have going on is that line 5 of your code has no way to tell if it should limit the entry information. With dynamic='no', you've said "EE, you don't need to use the URL here to figure out what entries to limit this by"
My suggestion would be the following code:
{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>{title}<span class="web-exclusive">MBNA Website Exclusive</span></h4>
<ul>
<li class="col-img">
<img width="116" height="84" alt="MBNA Platinum Credit Card" src="../lib-ui/img/cards/core/core_116x84/mbna_platinum_card_116x84.png">
</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>{title}<span class="web-exclusive">MBNA Website Exclusive</span></h4>
<ul>
<li class="col-img">
<img width="116" height="84" alt="MBNA Platinum Credit Card" src="../lib-ui/img/cards/core/core_116x84/mbna_platinum_card_116x84.png">
</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}
Mind you, this isn't 100% accurate, as I stripped out your exp:channel:categories tag, but this should get you a result that limits based on a shortened URL like you've specified.
So how do I get it to use this template file instead for a single
entry?
Instead of:
{url_title_path='credit-cards'}
Use
{title_permalink="credit-cards/single"}
There are two primary ways you can use the template 'credit-cards/single' for the VISA credit card category entry.
First Option
'credit-cards/index' template would have:
{if segment_2 != ""}
{embed="credit-cards/single" entry_id="{entry_id}"}
{/if}
'credit-cards/single' template would have:
<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}
Second Option
Rename 'credit-cards/single' to 'credit-cards/company' (or something more SEO relevant) and use it the default EE way.
'credit-cards/index' template would stay the same.
'credit-cards/company' template would have:
<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}
In this second option the url would be site.com/credit-cards/company/visa-credit-card
I hope that helps. Let me know if I've misunderstood anything.
You'll probably want something like this in the index template:
{if segment_2 != ""}
{exp:channel:entries channel="credit_cards"}
[single entry code...]
{/exp:channel:entries}
{if:else}
{exp:channel:categories category_group="1" style="linear" dynamic="no"}
[your code for all credit cards]
{/exp:channel:entries}
{/if}
What's happening is the URL /credit-cards/visa-credit-card is loading the index template of the credit-cards template group, but the visa-credit-card URL title at the end tells ExpressionEngine to treat the template as a single entry page.
But the the dynamic="no" in your exp:channel:entries tag is why EE is still showing all the credit cards on that page. This free video about dynamic="off" might explain it better.
Thanks for all the great suggestions. I used the pages modules in the end which allows you to specify which template to use.
Related
I copied the code below into the editor
<div class="services_container clearfix">
<a href="it" class="service service-it">
<div class="service_ttl">
IT support
</div>
<span>More</span>
</a>
<a href="legal" class="service service-legal">
<div class="service_ttl">
Legal support
</div>
<span>More</span>
</a>
But if I look in firebug, the code output looks like this
<div class="services_container clearfix">
<a class="service service-it" href="it/index.php">
<p></p>
<div class="service_ttl">IT support</div>
</a>
<p>
<a class="service service-it" href="it/index.php">
<span>More</span>
<br>
</a>
<br>
<a class="service service-legal" href="legal/index.php"></a>
</p>
<a class="service service-legal" href="legal/index.php">
<div class="service_ttl">Legal support</div>
</a>
<p>
<a class="service service-legal" href="legal/index.php">
<span>More</span>
That is tags is repeated two or three times and this breaks the page design.
Obviously I need in the writing settings disable option "WordPress should correct invalidly nested XHTML automatically".
But I don't have this option in the writing settings.
I have found and commented out all calls of force_balance_tags function.
Then I have deleted and recreated page, but it not helped.
I use Worpress 4.7.
I have a page which includes the menu bar (a php page). This works, but strangely the page doesn't load after the include.
Some code:
<div class="center">
<?php
include ('../menu.php')
?>
<div class="text" id="media">
Some text
</div>
When I add the
<div class="text" id="media">
Some text
</div>
to the menu.php it is showed, but not when it is on the parent page. Anybody has an idea? There isn't any warning or error showing.
<!-- begin menu -->
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<link rel="stylesheet" href="../../../../style/menu.css">
<div class="menu_b">
<div class="logo">
<img src="../../../../afbeeldingen/menu/logo.gif" width="375" title="Home" />
</div>
<div class="aangemeld">
</div>
<ul class="menu_tekst">
<li class="<?php echo $account_li;?>"><a class="nt" href="../../../../account.php">Account</a></li>
<li class="tussenstuk"></li>
<li class="<?php echo $contact_li;?>"><a class="nt href="../../../../contact.php">Contact</a></li>
<li class="tussenstuk"></li>
<li class="<?php echo $fotos_li;?>"><a class="nt" href="../../../../fotos.php">Foto's</a>
<ul class="sub_fotos sub">
<li class="space_left"> </li>
<li class="titel_blok_sub"><a class="nt" href="../../../../fotos/2013_2014.php">2013-2014</a></li>
<li class="titel_blok_sub"><a class="nt" href="../../../../fotos/kamp.php">Kampfoto's 2014</a></li>
</ul>
</li>
<li class="tussenstuk"></li>
<li class="nt"><a class="nt" href="../../../../winkelwagen.php">winkelwagen + besteld</a></li>
</ul>
</div>
<div class="onder_menu">
</div>
<div class="sub_menu">
</div>
<!-- einde menu -->
you forgot semicolon ;
include ('../menu.php');
You forgot a quotation mark:
<li class="<?php echo $contact_li;?>">
<a class="nt href="../../../../contact.php">Contact</a>
</li>
should be
<li class="<?php echo $contact_li;?>">
<a class="nt" href="../../../../contact.php">Contact</a>
</li>
Succes ermee
Above the div.center their was an other php include of a page that doesn't exist, after removing it, the page loaded. Didn't looked at it because it was above the menu.php which was loaded.
Try using require:
require('../menu.php');
I'm guessing that you have turned off display errors in your php.ini and that menu.php doesn't exist.
If you are not sure how to turn on error reporting in your development machine, add the following lines to your parent page;
<div class="center">
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
include ('../menu.php');
?>
<div class="text" id="media">
Some text
</div>
This should then reveal why the page is not being included.
Take the parenthesis off the include statement. It should look like this:
include 'page.php';
I have breadcrumbs in my master.blade.php file and i want the breadcrumbs to be used everywhere BUT the homepage.blade.php.
right now this is how i add links to the breadcrumbs in other pages like "About".
about.blade.php:
#section('breadcrumbs')
#parent
<li class="last-breadcrumb">
About
</li>
#stop
in the master.blade.php:
<div class="container">
<div class="breadcrumb-container">
<ul class="breadcrumb">
#section('breadcrumbs')
<li>
<a href="/homepage/" title="homepage">
homepage
</a>
</li>
#show
</ul>
</div>
</div>
but i don't want the breadcrumbs code to display at all when homepage.blade been used.
copying the code for each about.blade/X.blade files seems like a bad idea..
Your can set a value in your controller that you pass with the make/redirect like $data['breadcrumb'] = true and wrap your breadcrumb code in an conditional. This kind of system also works well for error and success messages since you can alse send content from your controller. Then you would send an array with values instead of true.
Blade template
<div class="container">
#if($breadcrumb)
<div class="breadcrumb-container">
<ul class="breadcrumb">
#section('breadcrumbs')
<li>
<a href="/homepage/" title="homepage">
homepage
</a>
</li>
#show
</ul>
</div>
#endif
</div>
You can check the URI to see if you want to display it or not. It's logic in your view which is usually frowned upon, but it's the easiest way I can come up with.
<div class="container">
<div class="breadcrumb-container">
<ul class="breadcrumb">
#if(Route::uri() == '/')
<li class="last-breadcrumb">
About
</li>
#endif
<li>
<a href="/homepage/" title="homepage">
homepage
</a>
</li>
#show
</ul>
</div>
</div>
Depending on the URI you are using for your home page, you may need to tweak the condition.
If you use #yield in your master template then it will only display content when the section has been defined. #content requires the section to be always defined.
I seem to be having an issue with the pagination on the news section appending an /index/ when using the {pagination_links} tag.
My news page has a template path of news/index and the posts template is news/post.
I am using structure with the news/post as a listing attached to the news/index page, to add|edit posts.
If you have a look at the website in question: http://www.wilbyltd.co.uk/news scroll to the bottom you will see the pagination, if you click either 1|2|3 or next page or last page you will get the page requested, the url looks like /news/P6, however now on this next page if you go to the pagination again and click any of them you will notice it has gone back to page 1 and the url has /news/index it seems to be appending or inserting between links /index/.
I have tried to the paginate_base="" in the channel entry but adding a base stops the categories from having a working pagination, categories also add /index/ between the links?
I have thought of hacking the core but seems the wrong approach just in case it ever gets updated.
I have tried .htaccess to remove the index, which didn't work.
RewriteRule ^/news/index/(.+)$ /news/$1 [L]
I have looked at the config for index.php which has been taken off and .htaccess has been used.
I have looked at the channel settings.
I have tried dynamic="off"|dynamic="on"
I understand that news/index it the correct path for the page to view, but if this is the case why doesn't it pick up the pagination?
If anyone could shed some light in to this I would be really grateful, here is the code containing the pagination.
{exp:channel:entries channel="posts" limit="6" dynamic="on" paginate="bottom" orderby="entry_date" sort="desc"}
<div class="news-snippet span9">
<a href="{url_title_path=">
<div class="date-published textalign-center">
<span class="day">{entry_date format="%d"}</span><span class="day-suffix">{entry_date format="%S"}</span>
<span class="month">{entry_date format="%F"}</span>
</div>
</a>
<div class="news-snippet-body pull-right">
<div class="news-snippet-top-shadow">
<div class="news-snippet-bottom-shadow">
<a href="{url_title_path=">
<div class="news-snippet-content clearfix">
<div class="title">
<h3>{title}</h3>
</div>
{if news_feature_image}
<div class="clearfix image">
<img src="{news_feature_image}" />
</div>
{/if}
<p>{news_short_description}</p>
</div><!-- end content -->
</a>
<div class="news-snippet-options clearfix">
<div class="news-tags pull-left">
<i class="icon-tags"></i>
{exp:tagger:tags entry_id="{entry_id}" }
<span class="label label-inverse tags">{tagger:tag_name}</span>
{/exp:tagger:tags}
</div>
<div class="social-share pull-right textalign-center">
<i class="icon-random"></i>
<a class="addthis_button"url="{url_title_path="title="{title}" href="http://www.addthis.com/bookmark.php?v=300&pubid=ra-5141a60a37fa6e4e">Share</a>
</div>
</div>
</div><!-- end bottom-shadow -->
</div><!-- end top-shadow -->
</div><!-- end snippet-body -->
</div><!-- end news-snippet -->
{paginate}
<div class="clearfix paginate">
{pagination_links}
<div class="total-pages pull-left">
<p>Page {current_page} of {total_pages} pages</p>
</div>
<div class="pagination pagination-mini pull-right">
<ul>
{first_page}
<li>First Page</li>
{/first_page}
{previous_page}
<li>Previous Page</li>
{/previous_page}
{page}
<li>{pagination_page_number}</li>
{/page}
{next_page}
<li>Next Page</li>
{/next_page}
{last_page}
<li>Last Page</li>
{/last_page}
</ul>
</div>
{/pagination_links}
</div><!-- end clearfix -->
{/paginate}
{/exp:channel:entries}
I have also had this on Ellis Labs forum for a couple of weeks: http://ellislab.com/forums/viewthread/237601/
Try to override the {paginate_base} parameter in your channel entries tag
{exp:channel:entries channel="posts" paginate_base="news/" ...}
http://ellislab.com/expressionengine/user-guide/modules/channel/channel_entries.html#paginate-base
i=0. I would like to make tab1, tab2,tab3, and so on inside foreach and also if i=1 then echo class="active" at first < li >. How to make it?
{elseif $complexField == "KeySkills"}
<ul>
{foreach from=$complexElements key="complexElementKey" item="complexElementItem"}
{foreach from=$form_fields item=form_field}
{if $form_field.caption == "Key personal skill"}
<li
(if i=1 then echo class="active")
><a href="#
tab1
" data-toggle="tab">{display property=$form_field.id complexParent=$complexField complexStep=$complexElementKey} </a></li>
{/if}
{/foreach}
{/foreach}
</ul>
<div class="tab-content" style="min-height:470px;">
{foreach from=$complexElements key="complexElementKey" item="complexElementItem"}
{if $form_field.caption == "Percentaged Key Skill" || $form_field.caption == "Skill Detail"}
<div class="tab-pane fade active in" id="
tab1">
<div class="item_top">
<p> {display property=$form_fields.SkillDetail.id complexParent=$complexField complexStep=$complexElementKey} </p>
<div class="donutchart2" data-percent="{display property=$form_fields.PercentKeySkill.id complexParent=$complexField complexStep=$complexElementKey}"></div>
</div>
</div>
{/if}
{/foreach}
</div>
Here is HTML source code
This answer is based you your title because your HTML isn't readable
{section name=foo loop=5}
{$smarty.section.foo.iteration}
{/section}
complexElementKey inside key of {foreach from=$complexElements key="complexElementKey" item="complexElementItem"} will be loop 1,2,3.
<a href="#tab{$complexElementKey}" data-toggle="tab"> will be <a href="#tab1" data-toggle="tab">blablabla
<a href="#tab2" data-toggle="tab"> bsdakdkas
<a href="#tab3" data-toggle="tab">gdfgdfg