I've create a blog using a few templates in ExpressionEngine 2, but am struggling with how to get pagination implemented in the main/list view. I can obviously reduce the entry limit and apply the paginate attribute to the channel tag, but it doesn't work properly. It simply outputs the pagination links, but each link simply goes to a standalone page with only the newest entry.
I feel as though I may be missing something obvious, but I'm really not sure. I'd appreciate it if anyone has any input/suggestions as to how to properly implement things.
{exp:channel:entries channel="notes_entry|notes_link|notes_photo|notes_quote|notes_video" limit="20" orderby="date"}
{if channel_short_name == 'notes_link'}
<div class="link">
<h2>{title}</h2>
{notes-link-description}
<span class="date">Posted on {entry_date format="%F %j, %Y"} | Permalink</span>
</div>
{if:elseif channel_short_name == 'notes_quote'}
<div class="quote">
<h2>{title}</h2>
<blockquote>{notes-quote}</blockquote>
<span class="source">{notes-quote-source}</span>
{notes-quote-description}
<span class="date">Posted on {entry_date format="%F %j, %Y"} | Permalink</span>
</div>
{if:elseif channel_short_name == 'notes_entry'}
<div class="entry">
<h2>{title}</h2>
<span class="author">Written by {author}</span>
<p>{notes-entry-summary} <span>Read More…</span></p>
<span class="date">Posted on {entry_date format="%F %j, %Y"} | Permalink</span>
</div>
{if:elseif channel_short_name == 'notes_photo'}
<div class="photo">
<h2>{title}</h2>
<img src="{notes-photo-upload}" alt="" />
{notes-photo-description}
<span class="date">Posted on {entry_date format="%F %j, %Y"} | Permalink</span>
</div>
{if:elseif channel_short_name == 'notes_video'}
<div class="video">
<h2>{title}</h2>
<div class="video-container">
<!-- start of embed code -->
{notes-video-embed}
<!-- end of embed code -->
</div>
{notes-video-description}
<span class="date">Posted on {entry_date format="%F %j, %Y"} | Permalink</span>
</div>
{/if}
{/exp:channel:entries}
Here's a simplified example of paginating multiple channel entries, using the Agile Records theme:
{exp:channel:entries channel="about|news" dynamic="on" limit="5" paginate="bottom"}
<p>
{if channel_short_name == "about"}
<!-- Link to the About Section Entries -->
{title}
{if:else}
<!-- Link to the News Section Entries -->
{title}
{/if}
</p>
{paginate}
<p>Page {current_page} of {total_pages} pages {pagination_links}</p>
{/paginate}
{/exp:channel:entries}
The output of the paginate tag pair results in the following markup:
<p>
Page 1 of 5 pages
<strong>1</strong>
2
3
>
Last ›
</p>
Which looks like the following unstyled HTML in a browser:
The creative use of the {channel_short_name} conditional allows this single code block to link to each respective section's correct single entry page URL:
About the Label
Getting to Know ExpressionEngine
Related
I have a list of posts and some of them has reactions, some not. I want to extract the number of reactions of each posts and the problem is that those who doesn't have, there is no HTML code.
I tried to debug using print.
print(len(driver.find_elements_by_xpath("//div[#class='occludable-update ember-view']")))
-----
Output: 4 - This is good, because I have 4 divs
print(len(driver.find_elements_by_xpath("//span[#class='v-align-middle social-details-social-counts__reactions-count']"))
----
Output:2 - This is good, because I have 2 posts that got reactions
When I tried to find if a posts got reactions,
print(len(driver.find_elements_by_xpath("//div[#class='occludable-update ember-view']")[1].find_elements_by_xpath("//span[#class='v-align-middle social-details-social-counts__reactions-count']")))
----
Output: 2 - Why? Because the second div is empty...
HTML CODE
<div class="occludable-update ember-view">
<ul class="social-details-social-counts ">
<li class="social-details-social-counts__reactions social-details-social-counts__item ">
<button class="social-details-social-counts__count-valuet " aria-label="1 Reaction’ post" type="button">
<img class="reactions-icon social-detail">
<span aria-hidden="true" class="v-align-middle social-details-social-counts__reactions-count">3</span>
</button>
</li></ul>
</div>
<div class="occludable-update ember-view"> this div has no reaction </div>
<div class="occludable-update ember-view"> this div has no reaction </div>
<div class="occludable-update ember-view">
<ul class="social-details-social-counts ">
<li class="social-details-social-counts__reactions social-details-social-counts__item ">
<button class="social-details-social-counts__count-valuet " aria-label="1 Reaction’ post" type="button">
<img class="reactions-icon social-detail">
<span aria-hidden="true" class="v-align-middle social-details-social-counts__reactions-count">3</span>
</button>
</li></ul>
</div>
to locate the continuation element, use .
try below :
driver.find_elements_by_xpath("//div[#class='occludable-update ember-view']")[1].find_elements_by_xpath(".//descendant::span[#class='v-align-middle social-details-social-counts__reactions-count']")
I found the problem. After better documenting myself, I found out that for sub-elements is used .// instead of //
print(len(driver.find_elements_by_xpath("//div[#class='occludable-update ember-view']")[1].find_elements_by_xpath(".//span[#class='v-align-middle social-details-social-counts__reactions-count']")))
I'm using the latest version of EE2 and a plugin called Exp:resso store.
I have products assigned to a category and for the most part all of this is working fine. Below is my code:
<div class="col-md-7">
{exp:channel:categories channel="products" style="linear"}
<section class="section accordion repeater">
<h3>
{category_name}
<div class="icon">
<img src="/assets/local/img/plus-icon.jpg" alt="">
</div>
</h3>
<div class="accordion-content">
{exp:store:search orderby="title" sort="asc" category="{category_id}"}
{exp:store:product entry_id="{entry_id}"}
<p class="accordion-download">
{title} - {price}
<span><img src="/assets/local/img/add-to-cart.jpg" alt="">Add to cart</span>
</p>
{/exp:store:product}
{/exp:store:search}
</div>
</section>
{/exp:channel:categories}
</div>
I'm trying to find a way to show a No products exist message if the category doesn't have anything inside of it. I've tried using {count}, {total_results} & {total_rows} to check if there aren't any products. Problem is everything I try is obviously wrong because nothing gets output :/
Thanks in advance
The store search tag is a wrapper for the channel entries tag pair so you would need to use the {if no_results} tag pair.
<div class="col-md-7">
{exp:channel:categories channel="products" style="linear"}
<section class="section accordion repeater">
<h3>
{category_name}
<div class="icon">
<img src="/assets/local/img/plus-icon.jpg" alt="">
</div>
</h3>
<div class="accordion-content">
{exp:store:search orderby="title" sort="asc" category="{category_id}"}
{exp:store:product entry_id="{entry_id}"}
<p class="accordion-download">
{title} - {price}
<span><img src="/assets/local/img/add-to-cart.jpg" alt="">Add to cart</span>
</p>
{/exp:store:product}
{if no_results}
There are no products
{/if}
{/exp:store:search}
</div>
</section>
{/exp:channel:categories}
</div>
Should also be mentioned if you are not creating a form for the to add the products to the cart you could use the {store_field_short_name:price} variable to reduce the number of queries on your page. Most store things such as sku, weight, measurements can all be access by using the field short name followed by :variable
With the code below, I am currently showing all the categories for the channel, but I only need to show the category or categories for each entry. They have been checkboxed in each seperate entry.
What am I missing?
{exp:channel:entries channel="news" dynamic="no" orderby="date" sort="desc" }
<article class="listing">
<h2>{title}</h2>
<p>Posted on: {entry_date format="%F %j, %Y"} in {exp:channel:categories channel="news" style="linear" show_empty="no"}
{category_name},{/exp:channel:categories}</p>
<p class="summary">{news_summary}</p>
<p style="margin-top: 10px;"><a href='{url_title_path='news/view'}'>Read More</a></p>
</article>
{/exp:channel:entries}
Problem was, I was using regular channel type tags for categories. The correct code for this is....
{exp:channel:entries channel="news" dynamic="no" orderby="date" sort="desc" }
<article class="listing">
<h2>{title}</h2>
<p>Posted on: {entry_date format="%F %j, %Y"} in
{categories backspace="1"}
{category_name},
{/categories}</p>
<p class="summary">{news_summary}</p>
<p style="margin-top: 10px;"><a href='{url_title_path='news/view'}'>Read More</a></p>
</article>
{/exp:channel:entries}
I'm building a custom theme. I need to override how the list of blog posts is rendered to match my desired look. I can't seem to figure out how to render the blog post's title( or any other piece of info for that matter ). All of my markup and hard coded info renders, but the dynamic data does not.
Inside of my theme folder "~/Views/Items/Content-BlogPost.cshtml":
<div class="media row-fluid">
<div class="span1 hidden-phone">
<!-- Date desktop -->
<div class="date-wrapper"><span class="date-m">Jan</span> <span class="date-d">20</span> </div>
<!-- Meta details desktop -->
<p class="meta muted"><i class="icon-user"></i>Alex </p>
</div>
<!-- PROBLEM IS HERE!!!!!!!!!!! Title does not render! -->
<div class="span11"><h1>#Display(Model.Content.Title)</h1>
<div class="media-body">
<div class="tags">coding / event</div>
<h4 class="title media-heading">a nec in sed hac ultrices cursus</h4>
<!-- Meta details mobile -->
<ul class="inline meta muted visible-phone">
<li><i class="icon-calendar"></i><span class="visible-desktop">Created:</span> Sun 20th Jan 2013</li>
<li><i class="icon-user"></i>Alex</li>
</ul>
<a href="blog-post.htm" class="media-object">
<img src="img/blog/ape.jpg" alt="Picture of frog by Ben Fredericson">
</a>
<p>#Display(Model.Content)</p>
<ul class="inline links">
<li><i class="icon-circle-arrow-right"></i>Read more</li>
<li><i class="icon-comment"></i>50 Comments</li>
</ul>
</div>
</div>
</div>
Thanks to Bertrand, I tracked down the way to do this.
Model.ContentItem.TitlePart.Title
I have a site I'm working on at the moment, in which I have a sidebar displaying the 10 most recent posts (titles as links). I'm calling this in with the Embed function.
Though when I am looking on the individual post itself, the list only displays the post title that I'm on.
My embedded code calls all 10 of the recent posts in a exp:channels entry normal way.
Is there something I've done wrong? Below is the code for the main blog page:
{embed="embeds/html_header"}
<!-- content -->
{embed="embeds/html_blog_top"}
<div class="container">
<div class="row">
{embed="embeds/html_blog_sidebar"}
{exp:channel:entries channel="blog" limit="1"}
<div class="span8">
<article>
<header class="postHeader">
<div class="row-fluid">
<div class="span3 postDate">{entry_date format="%d"}<span>{entry_date format="%F"}</span></div>
<div class="span9 postPic">
<div class="imgWrapper">
{blog_image}
</div>
</div>
</div>
</header>
<div class="row">
<section class="span6 offset2">
<h2>{title}</h2>
<p>{full_entry}</p>
<p><span class='st_sharethis' displayText='ShareThis'></span>
<span class='st_facebook' displayText='Facebook'></span>
<span class='st_twitter' displayText='Tweet'></span>
</p>
</section>
</div>
</article>
</div>
{/exp:channel:entries}
</div>
</div>
</section>
<!-- footer -->
{embed="embeds/html_footer"}
This is the sidebar embed:
<aside class="span4" style="float:right;">
<section class="widget search clearfix">
<h3>news</h3>
<p>
{exp:channel:entries channel="blog" limit="10" orderby="date"}
{title}<br>
{/exp:channel:entries}
</p>
</section>
<section class="widget">
<h3>Archives</h3>
<ul>
<li>
{exp:channel:month_links channel="blog"}
{month} {year}<br>
{/exp:channel:month_links}
</li>
</ul>
</section>
</aside>
Its just the bit with the news section that I can't seem to get as a full list on the individual page.
Add dynamic="no" to your embed entries loop and you should be good.
Also, if you want answers on ExpressionEngine questions more quickly, try posting to expressionengine.stackexchange.com