Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.
-
Daniel Eng #1
Pagination with CF
Hi, I am creating an online magazine. So whenever I call an article out from my
MS Access Database, it will display about 1000 characters of text. How do I
make ColdFusion separate these text into 4 pages of 250 characters each? Can
someone point me to a sample code? Thanks!
Daniel Eng Guest
-
Book Pagination (.indb) Continuous Pagination (HELP!)
THE DOCUMENT: I've been working on a book with 14 separate documents using the Book feature (.indb) which coordinates the separate chapters... -
Pagination
Hi! I would like to know if there is anyway we could paginate a document with Acrobat 6.0.2 Professional. Thanks a lot! -
Pagination help?
Looking for advice on the best way to do this: We're a daily newspaper with 8 page editors doing layout all at once — each editor has 5-7 pages... -
Pagination?
how to pagination by flex?who can help me? -
Pagination issue
I'm having a pagination problem with an artist's portfolio site I'm working on. I'm using PHP/MySQL and Dreamweaver MX 2004. Each page has... -
externalError #2
Re: Pagination with CF
Hi Daniel,
Check the attached code, it will need some enhancements such as caching the
query for better performance :) Anyway, create a table "test1" with the fields
"ID" and "Article" where the ID field is autonumber and the Article field is
memo. You will also need to setup a DSN called "test" and name this page
"test1.cfm" ... Goodluck and code is below:
--------------------------------------------------------------------------------
----------------
<!--- I suppose that this page is named test1.cfm --->
<!--- Set default parameters --->
<cfparam name="url.id" default="1">
<cfparam name="url.page" default="1">
<cfset maxChars=250>
<!--- A query to retrieve an article --->
<cfquery datasource="test" name="qArticle" maxrows="1">
SELECT ARTICLE FROM TEST1 WHERE ID=#URL.ID#
</cfquery>
<!--- Display page according to URL.page --->
<div style="background:EDEDED">
<cfoutput>#mid(qArticle.article,val(maxChars*(url. page-1)+1),maxChars)#</cfoutpu
t>
</div>
<!--- Display clickable page numbers according to maxChars --->
<div>
<cfloop from="1" to="#val(len(qArticle.article)\maxChars)#" index="i">
<cfoutput>
<a href="test1.cfm?page=#i#&id=#url.id#">Page #i#</a>
</cfoutput>
</cfloop>
</div>
externalError Guest
-
Daniel Eng #3
Re: Pagination with CF
Hey thanks! I haven't got down to trying this code yet but it certainly do look promising! Will feedback once I try it out. :)
Daniel Eng Guest
-
Daniel Eng #4
Re: Pagination with CF
Hey, thanks it works just like I wanted it to...
There's this one thing though... can I calculate it by words or sentences
instead of character? It looks really quite funny with the pages separated in
the middle of a word? Possible? Please help! :)
Daniel Eng Guest
-
dempster #5
Re: Pagination with CF
One way to do this is to extract the maximum number of characters you want to
display, then search backwards from the end of the string to find a word
delimiter such as a space, comma, period, etc. This snippet takes the first 250
characters and reverses them. It then searches for the first delimiter,
extracts the text from that point on, and reverses it back to normal order.
You'd also want to get the length of the final string to use as your starting
point for the next page.
-Paul
<CFSCRIPT>
temptext = Reverse(Left(qarticle.article,250));
showtext = Reverse(Mid(temptext,FindOneOf(". ?!",temptext),250));
</CFSCRIPT>
dempster Guest
-
Daniel Eng #6
Re: Pagination with CF
hey guys, i've been trying to get the script to pass the correct length to each
specific page but i can't seem to get it right... here's my code:
THIS PAGE: test.cfm
<cfparam name="url.PAGE" default="1">
<cfparam name="url.art_ID" default="">
<cfparam name="url.minChars" default="0">
<cfset maxChars=1500>
<cfset minChars=#url.minChars#>
<cfset nexChars=minChars + maxChars>
<cfquery name="getArticle" datasource="coredb" dbtype="odbc">
SELECT article.*
FROM article
WHERE article.art_ID=#url.art_ID#
</cfquery>
<CFSCRIPT>
countext = Reverse(Left(getArticle.art_content,nexChars));
showtext = Reverse(Mid(countext,FindOneOf(">",countext),maxCh ars));
</CFSCRIPT>
<cfoutput>#mid(showtext, val(maxChars*(URL.page-1)+1),maxChars)#</cfoutput>
<cfloop from="1" to="#maxPage#" index="i">
<cfoutput><a href="test.cfm?page=#i#&minChars=#totaltext#">#i#</a></cfoutput>
</cfloop>
Daniel Eng Guest
-
dempster #7
Re: Pagination with CF
The parameter you need to pass from one page to the next is the start
character. For example, if the first page finds a space at character 239, the
second page begins at character 240. It doesn't really matter what the page
number is, unless you want to show that. The code below should work but it
probably needs a little more work (checking for the last page, for example).
-Paul
<CFSET maxchars = 250>
<CFPARAM NAME="URL.startchar" DEFAULT="1">
<CFQUERY NAME="getArticle" DATASOURCE="coredb">
SELECT article FROM cnExtraArticles WHERE ArticleID = #URL.art_ID#
</CFQUERY>
<CFSCRIPT>
temptext = Reverse(Mid(getArticle.article,URL.startchar,maxch ars));
showtext = Reverse(Mid(temptext,FindOneOf('. ?!"',temptext),maxchars));
newstart = Len(showtext) + URL.startchar;
</CFSCRIPT>
<CFOUTPUT>#showtext#<BR>
<BR>
<A HREF="pages.cfm?art_ID=#URL.art_ID#&startchar=#new start#">Next Page</A>
</CFOUTPUT>
dempster Guest
-
Daniel Eng #8
Re: Pagination with CF
Hey thanks Paul. It definitely would work for now...
by the way, for the funtion FindOneOf can I get it to find one set of
characters (eg: "</p>") instead of "<", "/", "p", ">" individually? Thanks!
Daniel Eng Guest
-
dempster #9
Re: Pagination with CF
Use the Find or FindNoCase function to locate a substring in a string:
Find("</P>", article)
It returns the position of the substring.
-Paul
dempster Guest



Reply With Quote

