Re: [PHPLIB] example of extending table.inc needed From: xendra (xendra <email protected>)
Date: 01/25/00

Yes! There is an extremely easy way of doing this. What you need to do is
write a class that extends Table. Table has two "virtual" functions that do
nothing and are meant to be used for classes that extend Table. You will
want to look at the following Table functions:

  function table_heading_row_add_extra($data, $class="")
  {}

  function table_row_add_extra($row, $row_key, $data, $class="")
  {}

In your extended class, add these functions, but give them body. The first
function is called during the Table header creation. This allows you to add
more columns to the table. The second function is for extra column data
associated with each row.

Here's an example of the way I am using them in an extended class:

  function table_heading_row_add_extra($data, $class)
  {
    $this->table_heading_cell(0, "&nbsp;", $class);
  }

  function table_row_add_extra($row, $row_key, $data, $class)
  {
    global $sess, $PHP_SELF;

    # Add edit course url
    #
    # &edit=1&rows=1&courseid[0]=???
    #
    $url=sprintf("%s&edit=1?rows=1?courseid[0]=%s",
      $PHP_SELF, $data);

    printf("<td%s><a href='%s'>edit</a></td>\n",
      ($class?"class=$class":""), $url);
  }

Of course, you can put whatever you want into this function. This is just an
example.

Hope that helps...

Jeff

 ----- Original Message -----
> From: "Chaco Taco" <tacochaco <email protected>>
> To: <phplib <email protected>>
> Sent: Monday, January 17, 2000 6:21 AM
> Subject: [PHPLIB] example of extending table.inc needed
>
>
> Hi
> My situation is not uncommon but I haven't found much posted examples of
> subclassing table.inc to add hyperlinks. My program allows users to see a
> subset of data and I need to let them follow a link to get more info if
> desired. My table is showing an ID field that I can use for my query so it
> would help to see an example of table_cell() that has a conditional to add
a
> hyperlink.
>
> thanks in advance

-
PHP3 Base Library Mailing List. Send messages to <phplib <email protected>>.
To unsubscribe, send "unsubscribe" to <phplib-request <email protected>> in
the body, not the subject, of your message.