Pagination link not working on expression engine exp:search results.Page does not display the new result when pagination link is clicked.
{exp:search:total_results}</b>Result(s) for <b>{exp:search:keywords}
{exp:search:search_results entry_id={entry_id}
switch="#000000|#003300" status="Open"
dynamic="off" orderby="date" sort="desc"}
{exp:search:search_results switch="resultRowOne|resultRowTwo" paginate="bottom" limit="2"}
<?php $articlePath = "article";?>
{related_entries id="article_feature"}
{if title == "Bay Blog"}<?php $articlePath = "blog";?>
{/related_entries}
<b>{title}</b> from <em>{related_entries id="article_feature"}{title} {/related_entries}</em><br/>
{if:else}
<b>{title}</b> from <em>{related_entries id="article_feature"}{title} {/related_entries}</em><br/>
{/if}
{exp:trunchtml chars="250" inline="..."}
{article_body}
{/exp:trunchtml}
{related_entries id="article_issue"}
[ {title}] {/related_entries}
<br><br>
{if no_results}
Sorry!, Search result found!
{/if}
{/exp:search:search_results}
{paginate}
<div class='paginate'>
<span class='pagecount'>{page_count}</span>
</div>
{paginate}
When returning search results, use the auto_path variable when building your URLs:
{title}
Unlike other path variables, this variable does not require the Template Group and Template Name to be specified.
Instead, the path will automatically be determined by the Search Results URL setting for the channel in Channel Management.
Admin > Channel Administration > Channels > Preferences:
If you're using ExpressionEngine's Pages Module or Structure to create static pages, the following use case may be of help to you as well:
{if page_url == ""}
// If the Search Result is a Dynamic Page
{title}
{/if}
{if page_url != ""}
// If the Search Result is a Static Page
{title}
{/if}
You can also test to see what channel the search result is being fetched from and act on it conditionally:
{if channel_name == "about"}
{title}
{if:else}
{title}
{/if}
Related
How do I create a filter search in JSViews? Usually I'd grab the html element by its class with the .getElementsByClassName() and .value() methods and add a === comparison to satisfy the right criteria. How can I do something similar in JsViews
I've already tried to add listItem in the IF to match the value of the html input (search bar), but I don't know how to grab the value of the search element (JQuery would be easy using $(".search")), or compare it to the listItems using regExp.
{^{if list && list.length}}
<ul autoselectitem="true" tabindex="-1" operationalindex="1" allindex="1">
{^{for list}}
{{include tmpl="listItem" /}}
{{/for}}
</ul>
{{else}}
<p>Nothing Found</p>
{{/if}}
This currently displays all items in the list, however I only want the elements in the list to be displayed that match with RegEx the .value of an search HTML element:
<input type="text" class="search" data-link="search" placeholder="Search...">
So for example, if I type in "e" into the search bar, all the items in the list that don't have the letter "e" should disappear.
The code linked all work, but what i've tried has given me null pointer errors because I'm not grabing the input element correctly by its class or data-link. How could I do this in the simplest way possible? Thanks
Here is one way of doing it:
<script id="myTmpl" type="text/x-jsrender">
<input type="text" class="search" data-link="search" placeholder="Search...">
{^{if list && list.length}}
<ul autoselectitem="true" tabindex="-1" operationalindex="1" allindex="1">
{^{for list filter=~flt depends="search"}}
<li data-link="#data"></li>
{{/for}}
</ul>
{{/if}}
</script>
<div id="page"></div>
<script>
var myTmpl = $.templates("#myTmpl"),
data = {
list: ["a", "b"],
search: ""
},
helpers = {
flt: function(item, index, items) {
return item.indexOf(data.search) > -1;
}};
myTmpl.link("#page", data, helpers);
</script>
I'm working in my Umbraco based website, and I have a page that contains objects arranged in a grid, and the amount of objects is getting bigger so I'll need to create pagination to this page. How can I create the pagination?
I'm new with Umbraco and website development, sorry of this is a stupid question.
Thanks!
Have a look here
#if (Model.HasNext || Model.HasPrevious) {
<nav class="pagination" role="pagination">
#if (Model.HasPrevious) {
<a class="newer-posts" href="#Model.PreviousUrl">
<i class="fa fa-chevron-circle-left"></i> Newer
</a>
}
<span class="page-number">Page #(Model.CurrentPageIndex + 1) of
#Model.TotalPages</span>
#if (Model.HasNext) {
<a class="older-posts" href="#Model.NextUrl">
Older <i class="fa fa-chevron-circle-right"></i>
</a>
}
</nav>
}
This code is from Articulate Blog engine (Umbraco plugin). You must create a custom Pager model.
On a page I need to scrape (with node.js and cheerio), I have this pattern:
<h2>
<span id="2015"></span>
<span class="ignore-me"></span>
</h2>
<div>
<ol>
<li>
<a title="TITLE1" href="HREF1"></a>
<a class="image" title="ignore-me-1" href="ignore-me-1"></a>
</li>
...
<li>
<a title="TITLE2" href="HREF2"></a>
<a class="image" title="ignore-me-2" href="ignore-me-2"></a>
</li>
</ol>
</div>
I would like to extract a list with TITLEs an HREFs.
I am trying something like this:
$('h2 > span[id="2015"]').next('ol > li > a').each(function(index, element) {
console.log('title:', element.attr('title'), 'href:', element.attr('href'));
});
without success (each loop is never entered...).
Any suggestion?
The ol element isn't actually the next element of span#2015. The ol element is inside a div which is the next element of h2. The right tree traversal is :
$('h2 > span[id="2015"]')
.parent()
.next('div')
.find('ol > li > a:not([class])')
.each(function() {
var $el = $(this);
console.log('title:', $el.attr('title'), 'href:', $el.attr('href'));
});
The h2 tag does not have an ID, thus your selector finds no results, nothing to loop over.
You could easily do it by looping anchor tags.
$("a").each(function(i, e) {
if (e.attr('title') && e.attr('href')) console.log("... stuff ...");
});
Or you can give your h2 an id, or remove the id from your selector. Many ways to loop.
When using an asset publisher, you can change Display Settings in the asset publisher configuration panel. If you select the Abstracts display template, a new option will be available for you (Abstract Length). How can I add an option like that to my Application Display Templates (ADT) ?
Example for the Abstracts template :
Example for my custom template (Abstract Length not available):
You can use substring in velocity code written inside ADT built for news asset publisher, check below code to display 100 character only of about us page
#if (!$entries.isEmpty())
<div class="news">
#foreach ($entry in $entries)
#set($renderer = $entry.getAssetRenderer() )
#set($className = $renderer.getClassName() )
#if( $className == "com.liferay.portlet.journal.model.JournalArticle" )
#set( $journalArticle = $renderer.getArticle() )
#set( $document = $saxReaderUtil.read($journalArticle.getContent()) )
#set( $rootElement = $document.getRootElement() )
#set( $xPathSelector = $saxReaderUtil.createXPath("dynamic-element[#name='country-portal-image']") )
#set( $countryPortalImage = $xPathSelector.selectSingleNode($rootElement).getStringValue() )
#set( $xPathSelector = $saxReaderUtil.createXPath("dynamic-element[#name='country-portal-title']") )
#set( $countryPortalTitle = $xPathSelector.selectSingleNode($rootElement).getStringValue() )
#set( $xPathSelector = $saxReaderUtil.createXPath("dynamic-element[#name='country-flag-icon']") )
#set( $countryFlagIcon = $xPathSelector.selectSingleNode($rootElement).getStringValue() )
#set( $xPathSelector = $saxReaderUtil.createXPath("dynamic-element[#name='country-portal-about-us']") )
#set( $countryPortalAboutUs = $xPathSelector.selectSingleNode($rootElement).getStringValue().substring(0,100) )
#set( $link = $renderer.getURLViewInContext($renderRequest, $renderResponse, '') )
#set( $viewURL = $assetPublisherHelper.getAssetViewURL($renderRequest, $renderResponse, $entry))
#set($news-summary =$entry.getSummary($locale))
#set($date = $dateTool.format("dd/MM/yyyy hh:mm:ss", $dateTool.toDate( "EEE, dd MMM yyyy hh:mm:ss Z" , $entry.getPublishDate())))
<div class="new">
<h1 class="title">$entry.getTitle($locale)</h1>
$date
<img src="$countryFlagIcon"/>
<img src="$countryPortalImage"/>
<h3 class="sub-title">$countryPortalAboutUs</h3>
<p class="read-more">
Read More
</p>
</div>
#end
#end
</div>
#end
You can create JSP hook to customize Asset Publisher configuration.
The original configuration is rendered by /html/portlet/asset_publisher/configuration.portal.jsp.
In your hook, you can include the original jsp and then add your own preferences.
Example:
<%-- Include the original Asset Publisher configuration JSP. --%>
<%#include file="/html/portlet/asset_publisher/configuration.portal.jsp"%>
<%-- Read current value from portlet preferences. --%>
<% String abstractLength = portletPreferences.getValue("abstractLength", "100"); %>
<%-- Hidden div with custom input fields. --%>
<div id="customPreferences" style="display: none;">
<aui:fieldset label="fieldset.abstractLength">
<aui:input name="abstractLength" label="abstractLength" value="<%= abstractLength %>">
<aui:validator name="number"/>
<aui:validator name="min">1</aui:validator>
</aui:input>
</aui:fieldset>
</div>
<%-- JS code to place custom preferences at the end of Display Settings tab. --%>
<%-- It uses jQuery, but it's not a requirement. --%>
<script>
$(document).ready(function () {
// find div with custom preferences
var $customPreferences = $("#customPreferences");
// find the last fieldset on Display Settings tab
var displaySettingsLastFieldset = $(".nav-tabs:eq(1)").siblings("div:eq(1)").children().filter("fieldset").last();
// insert custom preferences after the last fieldset on Display Settings tab
$customPreferences.insertAfter(displaySettingsLastFieldset);
// show custom preferences
$customPreferences.show();
});
</script>
It is a good approach to extend the original JSPs - ie. include the original and then make the customization. This way, there's a good chance of a painless update to next Liferay versions.
For general guidelines on how to implement JSP hooks, see Liferay Developer's Guide.
You can get a list of all the available portletPreference values available to the asset publisher ADT using:
<#list portletPreferences?keys as prop >
<li>
${prop}
</li>
</#list>
So, for your example, you could get the abstract length value set by the user using:
abstractLength: ${portletPreferences.abstractLength[0]}
best way if you creating your own ADT then manage content length in ADT instead of unnecessarily hooking of AP jsp.
I have a template in smarty like this :
Template folder
home.tpl
article.tpl
category.tpl
var.tpl
In each template file (except var.tpl), i include the file var.tpl.
home.tpl have a structure in 1 column
article.tpl have a structure in 2 columns
My template files are like this (home example) :
{include file="$tpl_dir./var.tpl"}
<div class="span{$center_column}" id="center_column">
</div>
In order to change quickly the apparence of my website, i wrote the following lines in var.tpl :
{assign var=center_column_g value=['home'=>'12','article'=>'10'] scope="root"}
{assign var=center_column_default value='10' scope="root"}
{if $center_column_g[$page_name]}
{assign var=center_column value=$center_column_g[$page_name] scope="root"}
{else}
{assign var=center_column value=$center_column_default scope="root"}
{/if}
ps : $page_name is a global variable with the name of each template page.
So with var.tpl, if i can easy change the class of my div #center_column
I have a doubt with this code :
{if $center_column_g[$page_name]}
{assign var=center_column value=$center_column_g[$page_name] scope="root"}
{else}
{assign var=center_column value=$center_column_default scope="root"}
{/if}
Is it right to assign var center_column in the root scope ?