Re: designing a re-usable pager element
S Ahmed <[email protected]>
| Newsgroups | gmane.comp.web.freemarker.user |
|---|---|
| Message-ID | <CAG2rwuMeZ0_sYLys_PfNPL0oNB9tHo1eVk+J9Wvs8BenpL8Xdg@mail.gmail.com> |
1. I have to caculate the # of pages to display using the total_items and items_per_page variables that I will pass in. total pages = math.ceiling(total items / items per page) How can I do the above in freemarker? 2. how to create a loop, that loops x times? I have only used the #list syntax before. On Fri, Oct 12, 2012 at 5:31 AM, Daniel Dekany <[email protected]> wrote: > Friday, October 12, 2012, 3:39:59 AM, S Ahmed wrote: > > > I want to create a re-usable content piece that will display a pager, my > html looks like: > > > > <div class="pagination"> > > <ul> > > <li><a href="">Prev</a></li> > > <li class="active"><a href="">1</a></li> > > <li><a href="">2</a></li> > > <li><a href="">3</a></li> > > <li><a href="">Next</a></li> > > </ul> > > </div> > > > > Now to make it re-usable, I want to pass in the following information: > > > > 1. base_url e.g. www.example.com/post/list > > 2. current_page e.g. 3 > > 3. total items e.g. 100 > > 4. items per page e.g. 25 > > > > So given this information, I should see 4 page links (100 items / 25 = > 4): > > > > > > <div class="pagination"> > > <ul> > > <li><a > > href="www.example.com/post/list?page=2">Prev</a></li> > > <li><a href="www.example.com/post/list?page=1">1</a></li> > > <li><a href="www.example.com/post/list?page=2">2</a></li> > > <li class="active"><a > > href="www.example.com/post/list?page=3">3</a></li> > > <li><a href="www.example.com/post/list?page=4">4</a></li> > > <li><a > > href="www.example.com/post/list?page=4">Next</a></li> > > </ul> > > </div> > > > > > > How could I create a macro for this in freemarker? > > Where exactly you stuck in doing this? (Also, to answer this, one > should know how the data-model looks like. I suppose the number of > pages and the current page number is not calculated by FreeMarker, but > is coming through the data-model.) > > -- > Best regards, > Daniel Dekany > > > > ------------------------------------------------------------------------------ > Don't let slow site performance ruin your business. Deploy New Relic APM > Deploy New Relic app performance management and know exactly > what is happening inside your Ruby, Python, PHP, Java, and .NET app > Try New Relic at no cost today and get our sweet Data Nerd shirt too! > http://p.sf.net/sfu/newrelic-dev2dev > _______________________________________________ > FreeMarker-user mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/freemarker-user > ------------------------------------------------------------------------------ Don't let slow site performance ruin your business. Deploy New Relic APM Deploy New Relic app performance management and know exactly what is happening inside your Ruby, Python, PHP, Java, and .NET app Try New Relic at no cost today and get our sweet Data Nerd shirt too! http://p.sf.net/sfu/newrelic-dev2dev _______________________________________________ FreeMarker-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/freemarker-user