designing a re-usable pager element

S Ahmed <[email protected]>
Newsgroups gmane.comp.web.freemarker.user
Message-ID <CAG2rwuPRygOwjdGoj3jmp=v2btD-F9AeiKop5B3=_FpkGpHM-Q@mail.gmail.com>
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?

------------------------------------------------------------------------------
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
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.