Pagination on Single-Entry view in ExpressionEngine - pagination

I am building a website with ExpressionEngine as the CMS. There is a "Work" section that displays all the projects, and a detail view that shows each project individually. It is at this point, on the single-entry view that I would like to have "prev" and "next" pagination. In my tests I have made it work when the URL is "somedomain.com/index.php/work/detail/" but it does not work when the specific entry is part of the URL: "somedomain.com/index.php/work/detail/some_project/"
I've tried putting the pagination code outside of the {exp:weblog:entries} tag as well as within it, but to no avail. This is what my pagination code looks like:
{paginate}
<ul>
{if previous_page}
<li>< previous</li>
{/if}
{if next_page}
<li>next ></li>
{/if}
</ul>
{/paginate}

You are using pagination for lists of entries, what you need is the next / previous entry tags:
http://expressionengine.com/user_guide/modules/channel/entry_linking.html

Hmm. I'm not sure what the issue is here, as I've never used the {pagination} tag in that way. After checking out the docs, I see that the example code for prev/next links inside of the {pagination} tag is wrapped inside of an {exp:comment:entries} loop instead of the normal {exp:channel:entries} loop.
The docs aren't very clear about the scope of this particular feature of the {pagination} tag. You might want to double check that, in your {exp:channel:entries} loop, you haven't included pagination as a value in the disable parameter.
You could also check out the page in EE's user guide about Next/Prev Linking, which details the use of {exp:channel:next_entry} and {exp:channel:prev_entry} tags in place of the {pagination} tag that you've been using. I've used these tags without a hitch, so I definitely recommend trying them if you can't get your method to work.
Best of luck!

Related

Expression Engine- Show HTML within entries loop even if no results

New to Expression Engine. I have the following code:
{exp:channel:entries channel="blogposts" orderby="date" url_title="{segment_3}" limit="1"}
<div id="cat_head_section">
<div id="cat_title">
<div id="lower_bubble_heading" class="cat_title"><h5>{title}</h5></div>
</div>
</div>
<div id="category_main">
{if no_results}
<h2>Sorry, the post you were looking for either does not exist or has been deleted.</h2>
{/if}
{url_title}
</div>
{/exp:channel:entries}
When there are no results returned, I don't get any of the HTML returned (other than the heading), which is vital to the structure of the page. How do I solve this?
Thanks.
This answer assumes that the entry call you are making here is the main one on the page. If this call is really just for a sidebar or something then this answer may not apply.
Couple of things...
If you are building urls like EE "expects" you to you shouldn't have to specify which url segment to look for the url title. The 'url_title' parameter is generally useful when you are doing something that EE does not expect, such loading a specific entry other than the one that appears in the last segment.
If you are limiting your result to one entry, there's no need to specify an order.
Maybe the reason you think you need the 'url_title=' parameter is because you haven't taken a good look at 'require_entry='.
So we are down to this:
{exp:channel:entries channel="blogposts" limit="1" require_entry="yes"}
Now on to your question:
Think about why and how someone would end up asking for a page that you can't find.
Did the entry get deleted? Did someone retweet a mal-formed URL?
A. You may say these requests really call out for 404 response.
Serving a true 404 instead of a valid page with a "Sorry..." message ensures that the bad page will not be indexed by search engines...
To handle this you want EE's redirect tag.
{if no_results}
{redirect="404"}
{/if}
You'll want to have a genuinely helpful 404 page if you do this.
B. Alternatively you may say that when an entry can't be found you already have in mind a 'next best place' to sent the visitor -- better than your site's 404 page.
So if your visitor is looking for a blog entry that doesn't exist (say: /blog/entry/bad_page) the best place to send them would be to your blog index page (say: /blog). If you care about search ranking, then to the extent that the inbound link that is breaking had some SEO value, a 301 redirect here will help to confer that SEO value on to the page to which you are redirecting.
{if no_results}
{redirect='blog/' status_code="301"}
{/if}
The only thing that will show up if there are no results is what's in between the {if no_results} "if" statement. If you want more HTML in there, you just have to add it in there (which looks like you are duplicating it but you won't be because only one or the other will show up - results or no results).
Alternately, if you'd rather not duplicate the code you might choose to save yout HTML as a separate embedded template, and then pass the appropriate values to it as variable parameters. If no results, assign apologies to your variable values.
See http://ellislab.com/expressionengine/user-guide/templates/embedding.html

EE alternative to WordPress shortcodes?

Any way in Expression Engine to simulate Wordpress' shortcode functionality?
I want to abide by community rules, and there's a disclaimer when clicking in the "answer" section of an existing question that says I should actually ANSWER the question, not respond to other answers.
As such, I have the same question as the one above. I am a dev with roots in WordPress and I would like to mimic the behavior of WP shortcodes in Expression Engine. All I want to do is save a snippet of code as a template that can be re-used all across my site.
For example, if I want to use an accordion menu on several pages, I could just click click while editing a page and the code appears with placeholder content that the user/dev can then replace with real content). Do I need a graphic slideshow? Click click, define the images/headings/text overlays.
As I'm posting this, I'm about to scour the EE plug-ins library but since I haven't found anything before, I wanted to post here first.
I cover an approach that I've used before in http://www.tyssendesign.com.au/articles/cms/more-stash-examples/ along with a couple of other examples of using Stash.
Short answer: there is not such a thing ... yet. The Shortcode add-on is currently in beta.
Long answer for now: use custom fields. Example: a Matrix field for your accordion, with your columns defined, and add as many row as you like. Then add tags for that in your template.
Same with a Gallery - create a Gallery field (Matrix works great for this again), then add the code to your template to build the gallery.
If these fields are made optional, then they only appear on the front-end when used.
If you want to get fancy and inject these chunks of content into your main content area, you can use NSM Transplant to do so.
Here's a simplified snippet of code I use on one site to acheive this:
{exp:nsm_transplant:body}
{inline_media}
{exp:nsm_transplant:content id="media_{row_count}"}
<figure class="{alignment}">
{exp:ifelse parse="inward"}
{if image}
{if "{alignment}" == "aligncenter"}
{exp:ce_img:make src="{image:resized}" width="860" quality="80" output='<img src="{made_url}" alt="" />'}
{if:else}
{exp:ce_img:make src="{image:resized}" width="430" quality="80" output='<img src="{made_url}" alt="" />'}
{/if}
{if:elseif video}
{if "{alignment}" == "aligncenter"}
{exp:antenna url="{video}" max_width="860"}
{if:else}
{exp:antenna url="{video}" max_width="430"}
{/if}
{if:elseif gallery}
{gallery}{embed="galleries/_embed" entry_id="{entry_id}"}{/gallery}
{/if}
{if caption}<figcaption>{caption}</figcaption>{/if}
{/exp:ifelse}
</figure>
{/exp:nsm_transplant:content}
{/inline_media}
{content}
{/exp:nsm_transplant:body}
In this case authors use {media_1}, {media_2} etc, to embed photos, videos, and galleries inside the content.
Another solution you can look at is Content Elements, which allows a more freeform method of populating an entry with a single custom field.
Hope that helps!
You can also use global variables within EE templates. You cannot use EE tags inside templates, but global variables do work. So anything that you can save as a global variable (possibly including variables made with the addon Low Variables, but I have not verified that) can be included into an EE template.
So if you need static HTML, or images, or whatever, you can absolutely mimic quite a bit of shortcode functionality by creating global vars and invoking them using the ordinary {global_var_name} syntax inside an entry field. Note that EE tags inside global variables will not get parsed, though, so you cannot use this to do an end run around parsing restrictions!

how to hide Showing result text in liferay Search Container?

I am using liferay search container to display list of information, but in that liferay search container by default display number of records like "Showing 2 results". But in my case i don't want to display this. How can I remove this? Also attached the image of search container.
Suggestions are welcome.
You can do this with Javascript as suggested by Felix Christy:
Here are the quick steps :
Go to "Manage Page" section of the desired page (page on which you
dont want to show this text)
Go to javascript section add the following, its Alloy UI javascript framework which comes bundled with liferay:
AUI().ready(
function(customA) {
customA.all('.taglib-page-iterator').hide(); // this would hide **all** the elements which have the class "taglib-page-iterator"
}
);
The above javascript code can be included in the custom portlet's JSP itself (note the method and selector which I have changed), like:
<aui:script>
AUI().ready(
function(customA) {
customA.one('#my-portletID .taglib-page-iterator').hide(); // this would hide only **one** element (the first it finds) which has the css class "taglib-page-iterator" under an element with id="my-portletID".
}
);
</aui:script>
Another possible solution through Hook:
You can create a hook as mentioned by Sandeep Nair to hide the results-text but you can put a condition to check to hide only if the URL of the page is for which you want to hide this or can have a condition to check for the particular portlet you want to hide this result-text.
So it will work normally for other pages and portlet, but will hide for your page and certain portlets which you define. This is an idea and have not tried it yet, but I think it would work. You can use the themeDisplay object which is available on JSP pages to retrieve the portlet-id.
Hope this helps.
Thanks to Felix Christy for suggesting the solution through Javascript.
I thought of converting my comments to an answer for better visibility to other members of this wonderful community.
It is because you are using page-iterator in your search container. When the records exceeds the default delta the message above will be replaced by showing-x-of-y-results alongside page numbers and controls for navigating to next pages.
If you dont want this then you have to modify the jsp page using hook. The name of the jsp is showing_x_results.jspf and following snippet is what you are looking for to modify in that.
<c:otherwise>
<c:choose>
<c:when test="<%= total != 1 %>">
<%= LanguageUtil.format(pageContext, "showing-x-results", numberFormat.format(total)) %>
</c:when>
<c:otherwise>
<%= LanguageUtil.format(pageContext, "showing-x-result", numberFormat.format(total)) %>
</c:otherwise>
</c:choose>
</c:otherwise>
In order to remove that String for some specific page, please put a jQuery/javascript on the page, which will hide that particular div/span which is showing that text.
In this case, it will not be shown on that page, but it will be available and will be rendered elsewhere.
Here are the quick steps :
Go to "Manage Page" section of the desired page (page on which you dont want to show this text)
Go to javascript section add this $('.taglib-page-iterator').hide();
This will only work, if you have included jquery.js in your theme. So please do it.
At present, hook (or ext if you want an extreme solution) is the only way you can do it.
Override the showing_x_results.jspf Fragment and comment/remove what's unnecessary.
The only "properties" that are configurable through the portal-ext.properties are these (LR 6.0.5)
#
# Set the available values for the number of entries to display per page. An
# empty value, or commenting out the value, will disable delta resizing.
# The default of 20 will apply in all cases.
#
# Always include 20, since it is the default page size when no delta is
# specified. The absolute maximum allowed delta is 200.
#
search.container.page.delta.values=5,10,20,30,50,75
#
# Set the maximum number of pages available above and below the currently
# displayed page.
#
search.container.page.iterator.max.pages=25
#
# Set this to false to remove the pagination controls above or below
# results.
#
search.container.show.pagination.top=true
search.container.show.pagination.bottom=true
You can find the latest (LR 6.1GA) Search Container properties explained here: http://www.liferay.com/es/documentation/liferay-portal/6.1/user-guide/-/ai/search-container
I wouldn't recommend hiding it from the client end as it will most likely break if you decide to upgrade your Liferay Installation. Hook is a safe way out.

Expression Engine 2 Next/Previous Entry Linking with Full Entries List

I want to use the Next/Previous Entry Linking technique in EE2:
{exp:channel:next_entry}
<p>Next entry: {title}</p>
{/exp:channel:next_entry}
{exp:channel:prev_entry}
<p>Previous entry: {title}</p>
{/exp:channel:prev_entry}
When this works, I'm on a single entry ie. awesome.com/index.php/my-cool-entry, I can click page through the entries in that channel.
Is it possible to ALSO display a full list of the entries on this page while I'm looking at one article? I want to be able to show the list of entries as a way to navigate to a particular article.
Think of it like the way {pagination_links} builds links:
First Page < 1 2 3 > Last Page except instead of numbers I want to display parts of that entry, rather than just a number.
What bothers me is that {paginate} generates ugly URLs ie. awesome.com/index.php/articles/P1, I'd rather have awesome.com/index.php/articles/my-cool-entry. exp:channel:next_entry/prev_entry preserves the URL_title!
Is there a plug-in that can handle this kind of thing?
Embedding a template is the way to go.
Create a new template with an {exp:channel:entries} loop. Within that you can dump out the entries you want and display any info you want from them.
One thing to make sure of is to use the dynamic="no" parameter within the {exp:channel:entries}. It'll go something like this:
In your article page, embed another template:
{embed="article/full_list"}
And within the article/full_list template use a loop like:
{exp:channel:entries dynamic="no" channel="[YOUR CHANNEL]" LIMIT="10"}
{title}
{/exp:channel:entries}

Modx Revo Wayfinder: Add extra attribute to list item of current menu

Ref: Wayfinder on Modx Revo
I've been searching extensively and couldn't find the answer.
I find a very tricky situation trying to output an extra attribute with the list item that wraps the current menu (the menu link on of the page you're currently in).
For example:
Instead of just this line..
<li class="current">This is the menu</li>
I want..
<li class="current" value="1">This is the menu</li>
see value="1"
I tried creating a chunk in relation with the &hereTpl parameter but apparently this parameter is no longer valid in Wayfinder Revo (or is it?).
I think another possible route is if there's a way for a conditional inside the &rowTpl to render the needed attribute only for the current menu but again another brick wall.
I also tried the [[+wf.attributes]] (on the list item tag in the template chunk and put the needed attribute in the Link attributes of all the the resources/documents assuming it's going to render only when the resource/document is "current" but then the attribute is just outputted to all the menu items.
Could you share a thought? thanks so much for any help.
do the following:
[[Wayfinder? &hereTpl=`navHere` (INCLUDE OTHER PARAMETERS THAT YOU LIKE)]]
In the navHere tpl write the following piece of code:
<li class="current" value="1">[[+wf.linktext]]</li>[[+wf.wrapper]]
I understand this would work out. Hope to get a response from you.

Resources