Categories > TinyButStrong general >

display by page / to many page links on one line

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: quzi
Date: 2003-06-28
Time: 20:50

display by page / to many page links on one line

Hello,

I is use the the display by page and is very nicely doing. But I have problem that are is to many page links on one line. Is way to change this to only have 20 or 30 page links a line?

TBS is very nice. Is very thanks for such nice thing.

Quzi
By: Skrol29
Date: 2003-06-28
Time: 23:53

Re: display by page / to many page links on one line

Do you want to have only 20 links max, or several lines of 20 links ?
By: quzi
Date: 2003-06-29
Time: 20:39

Re: display by page / to many page links on one line

several lines of 20 links

Thanks you.
By: Skrol29
Date: 2003-06-29
Time: 23:41

Re: display by page / to many page links on one line

Hmm, it looks like a multi-columns display.
With 20 columns, it should be a bit heavy to do. But possible.

An other way is to make short links in a cell for which the width is limited to 20 links. Then others links will display in next line.
This means that links are simple text Url, not in td or table.
By: Pirjo Posio
Date: 2003-06-30
Time: 00:36

Re: display by page / to many page links on one line

Aren't the paging links are normally done like this:
<Prev 1 2 3 ... 9 10 Next>
So, you can go directly to max 10 pages from a page.
After that, you must get next page, from which you can again go to 10 new pages. I'm not sure, how to do that in TBS.
By: quzi
Date: 2003-06-30
Time: 07:05

Re: display by page / to many page links on one line

What is wanting do is what Mr. Pirjo saying. A line of 20 links, then another line of 20 links, until all links displayed.
By: Skrol29
Date: 2003-06-30
Time: 09:44

Re: display by page / to many page links on one line

Haaaa, ok.

Here is a small function wich returns an array for you navigation bar.
This array can be merged to a block in order to display the navigation bar, using the names 'key' and 'val'. 'key' for the page number and 'val' for the text to display.
Example : [nav_block.key]

$page_curr is the current page displayed
$width is 20 in your case
$page_nbr is optional and should be the total number of pages if known.

function m_getlinks($page_curr,$width,$page_nbr = False) {
  $page_min = $page_curr - ($page_curr % $width) + 1 ;
  $page_max = $page_min + width - 1 ;
  if ($page_nbr>0) $page_max = min($page_max,$page_nbr) ;
  $links = array() ;
  if ($page_min>1) $links[$page_min-1] = '<prev' ;
  for ($i=$page_min;$i<=$page_max;$i++) {
    $links[$i] = $i ;
  }
  if ($page_nbr>$page_max) $links[$page_max+1] = 'next>' ;
  return $link ;
}
By: quzi
Date: 2003-06-30
Time: 11:22

Re: display by page / to many page links on one line

I am not understand.

What is this? Example : [nav_block.key]

And how is use of return $link to put in HTML?

I am sorry for stupidness. I already written stuffs with TBS, but the display by page is difficulty on me.

Is many thanks with hairy weeds.
By: Skrol29
Date: 2003-06-30
Time: 12:04

Re: display by page / to many page links on one line

Yes, I was a bit short.

Here is an example on how to make a navigation bar using the previous m_getlinks() function.
It supposes that in your code you have set the variables $page_curr and $pag_nbr.

HTML:
<table><tr><td>
  <a href="script.php?page=[nav.key;block=td]">[nav.val]</a>
</td></tr><table>

PHP:
$links = m_getlinks($page_curr,20,$page_nbr) ;
$TBS->MergeBlock('nav',$links) ;

By: quzi
Date: 2003-06-30
Time: 12:28

Re: display by page / to many page links on one line

Is now good. I was thought something like this, but couldn't realizing hole thing. I is understand now. Very thanks
By: quzi
Date: 2003-06-30
Time: 21:32

Re: display by page / to many page links on one line

Hello,

Is works, but only for the "next". The "prev" has a same page number as the first really link in the line. I tryed fixxing it but could not do this.

Thanks you,
By: quzi
Date: 2003-07-01
Time: 19:57

Re: display by page / to many page links on one line

I finded way to do what I wants. I fixxed your routine. I hope that working OK for everthing.

function  m_getlinks($page_curr, $width, $page_nbr = 0)
{
    $links = array();
    $page_min = $page_curr - ($page_curr % $width) + 1 ;
    $page_max = $page_min + $width - 1 ;
    if($page_nbr > 0)
        $page_max = min($page_max, $page_nbr);
    if($page_min > 1)
        $links[$page_min-5] = ' << ';
    for($i = $page_min; $i <= $page_max; $i++)
        $links[$i] = $i;
    if($page_nbr > $page_max)
        $links[$page_max+1] = ' >> ';
    return $links;
}

Is very greatfull for newness of your assistnace.
By: robee
Date: 2003-08-15
Time: 10:54

Re: display by page / to many page links on one line

good day sir!..I tried to use your code, but it didnt work..care to tell me how you called the function (with live database from mysql) and how did you passed it on the html?
By: robee
Date: 2003-08-18
Time: 03:46

Re: display by page / to many page links on one line

seems like nobody responded...u see, we've created a link to call mysql and then when we adopted the < prev 123 next> pagination..but it didnt work..how can we pass a live mysql query to this particular function???
By: robee
Date: 2003-08-18
Time: 05:33

Re: display by page / to many page links on one line

here's how i do my page....

include_once("tbs_class.php") ;

//Connexion to the database
require('DB.php');

//Default value
if (array_key_exists("PageNum",$_GET)) {
  $PageNum = $_GET["PageNum"] ;
} else {
    $PageNum = 1 ;
} ;

//Default value
if (array_key_exists("RecCnt",$_GET)) {
  $RecCnt = intval($_GET["RecCnt"]) ;
} else {
    $RecCnt = -1 ;
} ;

$PageSize = 5 ;

$TBS = new clsTinyButStrong ;
$TBS->LoadTemplate("datasql.htm") ;

//Merge the block by page
$RecCnt = $TBS->MergeBlock("blk",$cnx_id,"SELECT * FROM tblHoldings where AgencyCode='SEI'",$PageSize,$PageNum,$RecCnt) ;
//Calculate the number of page
$PageCnt = ceil($RecCnt / $PageSize) ;
//Display the list of pages
$TBS->MergeBlock("pg","num",$PageCnt) ;

$TBS->Show() ;


mysql_close($cnx_id) ;
$TBS->Show() ;


and the template looks like this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>SERIAL MANAGEMENT</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="tbs_us_examples_0styles.css" rel="stylesheet" type="text/css">
</head>

<body>
<p align="center" class="title-page">Serial Results</p>
<table border="1" align="center" cellpadding="2" cellspacing="0">
  <tr bgcolor="#CACACA">
    <td width="50"><strong>HoldingsID</strong></td>
    <td width="150"><strong>Title</strong></td>
    <td width="50"><strong>AgencyCode</strong></td>
    <td width="100"><strong>MaterialType</strong></td>
  </tr>
  <tr bgcolor="#F0F0F0">
    <td>[blk.HoldingsID;block=row]</td>
    <td>[blk.Title;block=row]</td>
    <td> <div align="right">[blk.AgencyCode;block=row]</div></td>
    <td> <div align="center">[blk.MaterialType;block=row]</div></td>
  </tr>
  <tr bgcolor="#E6E6E6">
    <td>[blk.HoldingsID;block=row]</td>
    <td>[blk.Title;block=row]</td>
    <td> <div align="right">[blk.AgencyCode;block=row]</div></td>
    <td><div align="center">[blk.MaterialType;block=row]</div></td>
  </tr>
</table>
<p align="center">There are [blk.#] displayed lines.</p>
<p align="center">Number of products: [var.reccnt]</p>
<table border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="50" valign="top">
      <div align="left">Page : </div></td>
    <td width="20" valign="top">
      <div align="center"><a href="datasql.htm?PageNum=[pg.#]&RecCnt=[var.RecCnt]">[pg.#;block=td]</a><br>
        [var.PageNum;if [val]=[pg.#];then '*' ;else '']</div></td>
  </tr>
</table>
</body>
</html>

AND it didnt return the <prev 123 next> links...how can I do it??