Re: dealing with page numbers

Daniel Dekany <[email protected]>
Newsgroups gmane.comp.web.freemarker.user
Message-ID <[email protected]>
Thursday, December 13, 2012, 1:56:44 PM, khrypt wrote:

> Hi guys,
> I'm a new user of FM and I need some help from you.
> I'm working with some documents and encountered an issue I could not manage
> yet..
> So, int this documents there are some informations that may or may not
> appear. If they do appear I have to know the number of that page. Here is
> the issue. 
> By declaring a variable called pageNumber like:
> [#assign pageNumber = "<s p a n   id="pagenumber"/>" /] I can get the number
> of the page.

What do mean by you can get it? How? You have just assigned a constant
string to `pageNumber`. (Barring the syntactical error; I assume it
was `[#assign pageNumber = '<span id="pagenumber" />' /]`.) It means
nothing for FreeMarker, it's just an arbitrary sequence of characters
for it.

> But next, I need to remember this number. So I declare another variable
> controlPage like:
> [#assign controlPage = pageNumber /]

So now `controlPage` holds the same string constant. I guess you
expect something else to happen, but what exactly and why?

> ... And here is the issue... This *controlPage* will always evaluate
> as *<s p a n id="pagenumber"/>*

Since it's just a constant, yes.

> but I need to be just the value at that point/position where I've
> done the assignment.

The value of what at the point assignment? The current page number?
What keeps track of the current page number? Or if nothing yet, what
separates the pages? Because at those points you could increase a page
counter variable.

> Because if I'm printing the *controlPage* in all pages it will
> have the value of current page (ex. 2, 3, 4, 5...) even if my declaration
> was made somewhere on first page and I expect (1, 1, 1, 1, ...).

Um... the whole thing is rather strange. What are those spans, and why
are they relevant? How do you expect them to count the pages, if you
do at all?

> Thank you for your time.

-- 
Best regards,
 Daniel Dekany


------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.