www.webdeveloper.com
Results 1 to 11 of 11

Thread: page number menu at the bottom !

  1. #1
    Join Date
    Jul 2009
    Posts
    9

    page number menu at the bottom !

    Hi,

    I have a page which normally displays 10 items per page and shows the page numbers at the bottom of the page as below:

    <prev 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 next>

    where each of the above is a page number and each page displays 10 items in turn.

    There is a search option on this page which can be used to search the items by 'keywords' or 'categories'. When the search is done say, with a keyword 'sports', it displays the correct number of items but the page numbers at the bottom of the page displays the whole menu rather than showing,

    <prev 1 2 next>

    if there are under 20 items corresponding to that item search.

    I am new to javascript and would like to know how the correct page number menu can be displayed based on the number of items pulled for each 'category' or 'keyword'.

    Many Thanks!

  2. #2
    Join Date
    May 2008
    Posts
    30
    It seems to me like you may be referring to a server-side language, like php, ruby or python. Most pagination isn't done on the front-end, unless you're using ajax. Can you describe what you use for your back-end scripting? ...and how it connects to your javascript?

  3. #3
    Join Date
    Jul 2009
    Posts
    9
    Hi,

    The server-side language is php, can you pls tell me how to find the connection between php and javascript ?

    Thanks!

  4. #4
    Join Date
    May 2008
    Posts
    30
    I am sorry. I must have miread your initial question. I was assuming you wanted to control the actual pagination with javascript. The amount of links displayed should be governed by your php scripting. If you're using a CMS, like wordpress, or if you're using some MVC framework, you're going to have to look for the view helper that controls your pagination. The amount of links displayed should be the amount of pages your application returns. This is the amount of total results divided by the rows per page. The page number is the offset in your database query that tells it where to start. It's the offset + 1 for readability, ie. page 0 is 1 and so on. So, you're going to need to work with whomever writes your back-end scripting and have them change that. This problem cannot be solved using javascript, which is what this particular thread is for. So, in short, your php has to deal with echoing out the correct amount of links. Google the term pagination, should you need to get some more information.

  5. #5
    Join Date
    Jul 2009
    Posts
    9
    Hi,

    You are right, below is the code that is doing it in php. We use a software called PRADO. The code looks correct to me but displays all the page numbers at the bottom rather than 2 pages for an item count between 10-20.

    Any thoughts ?

    Many Thanks!

    if (($group_count > 10)) {
    $page_count = floor($group_count / 10) + 1;
    $page_count = $page_count > 15 ? 15 :
    $page_count;
    this->pager->setPageCount($page_count);
    }

  6. #6
    Join Date
    May 2008
    Posts
    30
    OK. I see what they're doing in the controller. Can you post the template/view code, where they actually echo out the pagination links?

    If it's just a function like:
    Code:
    $this->pager->whateverfunctionhere($inputOfSomeSort);
    ....then can you find the view helper that creates it or the documentation? It might be just something that 'pager' needs, like an optional parameter or something.

  7. #7
    Join Date
    Jul 2009
    Posts
    9
    Hi,

    I am guessing below is the code from the template:

    <div class="clear"></div>
    <com:GrResultsPager ID="pager" />
    <div class="clear"></div>

    Thanks!

  8. #8
    Join Date
    Jul 2009
    Posts
    9
    Hi,

    I am not sure if it the below code that u are want to view.

    Many Thanks!

    <div class="cnt" id="profile">
    <com:TPanel ID="options_panel" CssClass="options">
    <com:TLinkButton ID="reset_search_link" Text="reset search" Attributes.Style="float:right;" OnClick="resetSearch"/>

    <div class="search_details">
    <com:TActiveLabel ID="result_count"/>&nbsp;
    </div>
    </com:TPanel>

    <div class="results">
    <div class="search_details">
    <com:TRepeater ID="filter_labels">
    <prop:HeaderTemplate>
    <ul class="message_alerts">Current Filters:&nbsp;
    </prop:HeaderTemplate>
    <prop:FooterTemplate>
    </ul>
    </prop:FooterTemplate>
    <prop:ItemTemplate>
    <li class="offers"><com:TLinkButton onCommand="Page.onRemoveFilter"
    CommandName="filter" CommandParameter="<%#$this->Data['Value'] %>" ><%#$this->Data['Text'] %>
    </com:TLinkButton>
    </li>
    </prop:ItemTemplate>
    </com:TRepeater>
    </div>

  9. #9
    Join Date
    May 2008
    Posts
    30
    Hey,

    I am not familiar with PRADO at all. I tried going through their docs, but they're a bit clumsy, IMHO. I broke their search like so:

    http://www.pradosoft.com/demos/quick...h&q=com&#37;3A

    Weird....as it looks like they're using Zend to build their site and not their own framework! lol

    I am pretty sure they shouldn't be showing us that, but whatever.

    OK, so here is the documentation page on PRADO's pager:
    http://www.pradosoft.com/docs/manual...ls/TPager.html

    The only thing I can think of is this: when it doesn't get a result set larger than 10, it must default to something else. I mean, if you have 10 results and 10 results per page, you still have 1 page. I am not sure if you have to set this, either way, or not.

    I'd suggest trying to set the page count, no matter what. I would think the pager should take care of dealing with showing it or not. If that doesn't work, I am out of suggestions. You may want to hop on the PRADO forum and see if they have any suggestions. Wish I could be of more help. ......but try setting the page count no matter how many results there are....if there's one page...set it to one....
    Last edited by polygone; 07-15-2009 at 03:54 PM.

  10. #10
    Join Date
    Jul 2009
    Posts
    9
    Hi,

    Thanks for your response. If you look at the below code, the line in bold is doing that, either way setting the page count depending on the records returned but this is not working in actuality.

    I tried refering to the documentation and did not find anything useful.

    Is there a way to write a custom php function that could do this?

    Thanks!


    if (($group_count > 10)) {
    $page_count = floor($group_count / 10) + 1;
    $page_count = $page_count > 15 ? 15 : $page_count;
    this->pager->setPageCount($page_count);
    }

  11. #11
    Join Date
    May 2008
    Posts
    30
    Change this:

    PHP Code:
    if (($group_count 10)) {
    $page_count floor($group_count 10) + 1;
    $page_count $page_count 15 15 $page_count;
    this->pager->setPageCount($page_count);

    to this:

    PHP Code:
    $page_count = ((floor($group_count 10) + 1) > 15) ? 15 floor($group_count 10) + 1
    $this->pager->setPageCount($page_count); 
    ...and see if that works....

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles