2017 © Pedro Peláez
 

cakephp-plugin cakephp-thread-utility

Utility class to handle threaded data which genereted by CakePHP Model::find('threaded')

image

zuborawka/cakephp-thread-utility

Utility class to handle threaded data which genereted by CakePHP Model::find('threaded')

  • Tuesday, February 4, 2014
  • by zuborawka
  • Repository
  • 0 Watchers
  • 0 Stars
  • 3 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

cakephp-thread-utility

Utility class to handle threaded data generated by CakePHP Model::find('threaded'), (*1)

http://blog.xao.jp/blog/cakephp/reconstruct-threaded-data-to-table-rows/, (*2)

Usage

in CategoriesController

// Category model acts as Tree, (*3)

$threaded = $this->Category->find('threaded');
$tableRows = ThreadUtility::threadToRows($threaded);

in view

<table>
  <tbody>
  <?php
  foreach ($tableRows as $tableRow):
    ?>
    <tr>
    <?php
    foreach ($tableRow as $tableCell):
      $colspan = $tableCell['colspan'] > 1 ? ' colspan="' . $tableCell['colspan'] . '"' : '';
      $rowspan = $tableCell['rowspan'] > 1 ? ' rowspan="' . $tableCell['rowspan'] . '"' : '';
      $name = h($tableCell['Category']['name']);
      printf('<td%s%s>%s</td>', $colspan, $rowspan, $name);
    endforeach;
    ?>
    </tr>
    <?php
  endforeach;
  ?>
  </tbody>
</table>

an example of output

<table>
  <tbody>
    <tr>
      <td rowspan="2">Music</td>
      <td>Pops</td>
    </tr>
    <tr>
      <td>Jazz</td>
    </tr>
    <tr>
      <td colspan="2">Architecture</td>
    </tr>
    <tr>
      <td>Food</td>
      <td>Pasta</td>
    </tr>
  </tbody>
</table>
Music Pops
Jazz
Architecture
Food Pasta

The Versions

04/02 2014

dev-master

9999999-dev https://github.com/zuborawka/cakephp-thread-utility

Utility class to handle threaded data which genereted by CakePHP Model::find('threaded')

  Sources   Download

MIT

The Requires

 

by Avatar zuborawka

plugin cakephp table utility rows threaded

03/02 2014

v1.0

1.0.0.0 https://github.com/zuborawka/cakephp-thread-utility

Utility class to handle threaded data which genereted by CakePHP Model::find('threaded')

  Sources   Download

MIT

The Requires

 

by Avatar zuborawka

plugin cakephp table utility rows threaded