File Name: ListStories
File Submitter: lloyd_borrett
File Submitted: 6 Apr 2007
File Category: Blogs & News
// -----------------------
// Snippet: ListStories
// -----------------------
// Version: 0.6j-alpha
// Date: 2007-03-29
// WARNING: This is an unfinished alpha version
// If it works for you, great. If not, fix it yourself! :-)
//
// This snippet was designed to produce a paginated list
// of the active documents in an unpuplished folder,
// with links to the full story.
// For an example of it in use, see http://www.hmascanberra.com.au/in-the-news.htm
// Changes by Lloyd Borrett
// Version: 0.6j-mollio 2006-04-20
//
// Original Author: lloyd@borrett.id.au
// Adapted from I can't remeber what!
Click here to download this file
[Snippet] ListStories
Started by lloyd_borrett, Apr 06 2007 07:07 AM
4 replies to this topic
#1
Posted 06 April 2007 - 07:07 AM
#2
Posted 18 April 2007 - 01:08 PM
Hi Llloyd,
I have modified your snippet a little bit in order to make it work with a fullstory splitter. Basically, I have merged your snippet with the NewsListingRev03 snippet.
Instead of just displaying pagetitle, longtitle and description, you can now have the full story or an excerpt.
You can check out the modified snippet on this page.
I have modified your snippet a little bit in order to make it work with a fullstory splitter. Basically, I have merged your snippet with the NewsListingRev03 snippet.
Instead of just displaying pagetitle, longtitle and description, you can now have the full story or an excerpt.
You can check out the modified snippet on this page.
// CONFIGURE
// MAIN SNIPPET SETUP OPTIONS
// --------------------------
// $resultsPage [int]
// The default behavior is to show the results on
// the current page, but you may define the results
// page any way you like. The priority is:
//
// 1- snippet variable - set in page template like this:
// [[ListStories?FSF_landing=int]]
// where int is the page id number of the page you want
// your results on
// 2- querystring variable FSF_form
// 3- variable set here
// 4- use current page
//
// This is VERY handy when you want to put the search form in
// a discrete and/or small place on your page- like a side
// column, but don't want all your results to show up there!
// Set to results page or leave 0 as default
$resultsPage = 0;
// $showResults [1 | 0] (as passed in snippet variable ONLY)
// You can define whether this snippet will show the results
// of the search with it. Do this by assigning the snippet
// variable FSF_showResults as:
// [[FlexSearchForm?FSF_showResults=0]]
//
// This is useful in situations where you want to show the
// search results in a different place than the search form.
// In that type of situation, you would include two of these
// snippets on the same page, one showing results, and one
// showing the form.
//
// Default is true.
// $grabMax [ int ]
// Set to the max number of records you would like on
// each page. Set to 0 if unlimited.
$grabMax = 15;
// $pageLinkSeparator [ string ]
// What you want, if anything, between your page link numbers
$pageLinkSeparator = " ";
// $xhtmlStrict [ true | false ]
// If you want this form to validate as XHTML Strict compliance, then
// this needs to be true, but IE has a fieldset bug that I don't know
// a workaround for. So you can set this to false to avoid it.
$xhtmlStrict = false;
$use_splitter = 1; // shall the article be cut off at the *splitter*? 1=yes, 0=no
$link_char = "»"; // this character indicates a hyperlink, you could also do something like
// $link_char = "<img src='manager/media/images/icons/b01.gif'>";
$link_characters = " ".$link_char; // a set of characters which will be appended to links
// i.e. Full Story-> Older news-> etc.
$fullstoryprfx = " "; // prefix for "Full Story" but not part of the hyperlink
// to seperate things a bit, makes the result look prettier
$fullstorytext = "more "; // the text to show as full story link.
// Note that you must write special
// characters as html entities.
// if left blank, no "Full Story"-link will be generated.
$lentoshow = 50; // how many characters to show of blogs
$splitter = "[!FullStory!]"; // indicates the end of the short portion and the beginning of the
// "full story" - this has to be "written" manually in
// the article's text in HTML-mode (without the apostrophes of course)!
// the [!!] makes it a comment which is automatically invisible
// within the article.
// LANGUAGE AND LABELS
// --------------------------
// $resultsIntroFailure
// If nothing is found for the search. You should give the user
// some indication that the search was a failure.
$resultsIntroFailure = "No results found.";
// $resultsFoundTextSingle, $resultsFoundTextMultiple
// The string that will tell the user how many results were found.
// two variables will be provided at runtime:
// %d The number of results found (integer)
// %s The search string itself.
$resultsFoundTextSingle = '%d item';
$resultsFoundTextMultiple = '%d items';
// $paginationTextSinglePage and $paginationTextMultiplePages [ string ]
// The text that comes before the links to other pages. In this
// example, "Result pages: " was the $paginationTextMultiplePages:
// Result pages: 1 | 2 | 3 | 4
// Page numbers will only appear if there is more than one page.
$paginationTextSinglePage = 'page ';
$paginationTextMultiplePages = 'pages ';
// -------------
// End configure
// -------------
// the folder that contains news entries
// passed as argument "folder" or default to current document id
$resourceparent = isset($folder) ? $folder : $etomite->documentIdentifier;
// establish whether to show the results or not
$showResults = (isset($FSF_showResults))? $FSF_showResults : true;
// establish results page
if (isset($FSF_landing)){ // set in snippet
$searchAction = "[~".$FSF_landing."~]";
} elseif ($resultsPage > 0){ // locally set
$searchAction = "[~".$resultsPage."~]";
} else { //otherwise
$searchAction = "[~".$etomite->documentIdentifier."~]";
}
// Set newline variable
$newline = "\n";
//check for offset
$offset = (isset($_GET['ls_offset']))? $_GET['ls_offset'] : 0;
// initialize output
$output = '';
if ($showResults) {
$resource = $etomite->getActiveChildren($resourceparent, 'createdon', 'DESC', $fields='id, alias, pagetitle, longtitle, description, content, createdon');
$limit = count($resource);
if($limit>0) {
// pagination
$showPagination = false;
if ($grabMax > 0){
$numResultPages = ceil($limit/$grabMax);
$resultPageLinkNumber = 1;
$resultPagePrevious = '';
$pagePrevious = 0;
$resultPageNext = '';
$pageNext = 0;
$resultPageNumbers = '';
for ($nrp=0;$nrp<$limit && $limit > $grabMax;$nrp+=$grabMax){
if($offset == ($resultPageLinkNumber-1)*$grabMax){
$resultPageNumbers .= '<b>'.$resultPageLinkNumber.'</b>';
$pageCurrent = $resultPageLinkNumber;
if ($pageCurrent > 1) {
$resultPagePrevious = $resultPageLink;
$pagePrevious = $pageCurrent - 1;
}
if ($pageCurrent < $numResultPages) {
$pageNext = $pageCurrent + 1;
}
} else {
$resultPageLink = '<a href="[~' . $etomite->documentObject['id'] . '~]';
$resultPageLink .= '&ls_offset=' . $nrp;
$resultPageLink .= '" title="Page '.$resultPageLinkNumber.'">';
$resultPageNumbers .= $resultPageLink . $resultPageLinkNumber . '</a>';
if ($resultPageLinkNumber == $pageNext) {
$resultPageNext = $resultPageLink;
}
}
$resultPageNumbers .= ($nrp+$grabMax < $limit)? $pageLinkSeparator : '';
$resultPageLinkNumber++;
}
// built the page links paragraph
$resultPageLinks = '<p>';
if ($pagePrevious == 0) {
$resultPageLinks .= '';
} else {
$resultPageLinks .= $resultPagePrevious.'« Previous</a>';
}
$resultPageLinks .= $pageLinkSeparator.$resultPageNumbers.$pageLinkSeparator;
if ($pageNext == 0) {
$resultPageLinks .= '';
} else {
$resultPageLinks .= $resultPageNext.'Next »</a>';
}
$resultPageLinks .= '</p>'.$newline;
// add the text
$resultPageLinks .= '<p>';
if ($limit>$grabMax) {
$resultPageLinks .= $paginationTextMultiplePages;
$showPagination = true;
} else {
$resultPageLinks .= $paginationTextSinglePage;
$showPagination = false;
}
$resultPageLinks .= $pageCurrent.' von '.$numResultPages.'</p>'.$newline;
// show number of results
$output .= '<p class="success">';
$resultsFoundText = ($limit > 1)? $resultsFoundTextMultiple : $resultsFoundTextSingle;
$output .= sprintf($resultsFoundText,$limit);
$output .= '</p>'.$newline;
// add the pagination bar if required
if ($showPagination) {
$output .= '<div class="pagination">'.$newline.$resultPageLinks.'</div> <!--end pagination-->'.$newline;
}
} // end if grabMax
// search results
$useLimit = ($grabMax > 0)? $offset+$grabMax : $limit;
for ($y = $offset; ($y < $useLimit) && ($y<$limit); $y++) {
$SearchFormsrc=$resource[$y];
//====== Splitter to be used? =====
if (1 == $use_splitter)
{
if (is_string(strstr ($SearchFormsrc['content'], $splitter)))
// Does the content contain the socalled "splitter"?
{
$rest = array();
$rest = explode($splitter,$SearchFormsrc['content']);// HTMLarea/XINHA encloses it in paragraph's
$rest = explode($splitter,$rest['0']); // For TinyMCE or if it isn't wrapped inside paragraph tags
$rest = $rest['0'];
if ("" != $fullstorytext)
{
$rest .= $fullstoryprfx.'<div align=right><i><a href="[~'.$SearchFormsrc['id'].'~]">'.$fullstorytext.$link_characters.'</a></i></div>';
}
}
else
{
$rest = $SearchFormsrc['content'];
}
}
//======= End of splitter-part ===
else //=== no splitter ... normal behaviour: ===
{
// strip the content
if(strlen($SearchFormsrc['content'])>$lentoshow)
{
$rest = substr($SearchFormsrc['content'], 0, $lentoshow);
if ("" != $fullstorytext)
{
$rest .= "...<br />".$fullstoryprfx."<a href='[~".$resource[$x]['id']."~]'>$fullstorytext$link_characters</a>";
}
}
else
{
$rest = $SearchFormsrc['content'];
}
}
// start result
//EDIT HERE FOR YOUR STYLE
$output .= "<p><a href='[~".$SearchFormsrc['id']."~]'>".$SearchFormsrc['pagetitle']."</a></p>
<p>".$rest."</p>
<p align=right><i>Added ".strftime("%d.%m.%y", $SearchFormsrc['createdon'])."</i></p>";
}
// repeat the pagination bar if required
if ($showPagination) {
$output .= '<p>'.$newline.$resultPageLinks.'</p><!--end pagination-->'.$newline;
}
} else {
$output .= '<p class="error">'.$resultsIntroFailure.'</p>'.$newline;
} // end if records found
} // end if showResults
return $output;
Edited by Psycho Mantis, 27 August 2007 - 11:29 AM.
codeboxed
#3
Posted 22 June 2007 - 10:27 PM
dunno if it wad built in but as far as i know you only could set 1 number of bolgs fetched
well i only wanted 1 post on my home page and 15 per page on my news page so i added this line
after config
well i only wanted 1 post on my home page and 15 per page on my news page so i added this line
after config
//maybe you don't want all news on 1 page $grabMax = (isset($max))? $max : $grabMax;altered this too
//maybe you don't want to show how many items you have on all pages
$shownum = (isset($shownum))? $shownum : true;
// show number of results
if($shownum){
$output .= '<p class="success">';
$resultsFoundText = ($limit > 1)? $resultsFoundTextMultiple : $resultsFoundTextSingle;
$output .= sprintf($resultsFoundText,$limit);
$output .= '</p>'.$newline;
}
#4
Posted 24 June 2007 - 04:25 PM
added headliners too :
//for displaying of headliners i only need the titles
if($headliners=="true"){
$output .= "<span><a href='[~".$SearchFormsrc['id']."~]'>".$SearchFormsrc['pagetitle']."</a></span><br />";
}else{
// start result
//EDIT HERE FOR YOUR STYLE
$output .= "<span class=\"newstitle\"><a class=\"newstitle\" href='[~".$SearchFormsrc['id']."~]'>".$SearchFormsrc['pagetitle']."</a></span>
<p class=\"newscontent\">".$rest."</p>
<span align=left><i>Toegevoegd op ".strftime("%d.%m.%y", $SearchFormsrc['createdon'])."</i></span><br /><hr />";
}
}
$len = strlen($output);
$output = substr($output,0,$len-6); //delete last <hr />
#5
Posted 26 April 2008 - 06:36 PM
I can't get the snippet 'ListStories' to work on my website. A bit frustrating because I've seen the snippet on the websites of Lloyd and Psycho Mantis and I think the snippet is very usefull.
Lloyd used in the BETA version:
Time for a stable version, because I love this snippet (very complete). Who can help ?
Thanks
Ted
Lloyd used in the BETA version:
[[FlexSearchForm?FSF_landing=int]]and Psycho Mantis used:
[[ListStories?FSF_landing=int]]
Time for a stable version, because I love this snippet (very complete). Who can help ?
Thanks
Ted
Edited by Ted Donkers, 26 April 2008 - 06:38 PM.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











