LoginSignup
0
0

More than 5 years have passed since last update.

CakePHP 1.3 TreeView Behavior のchildrenに追加の条件を追加する

Last updated at Posted at 2016-06-03

今更ですが他に情報が載って無かったのでメモ書き。

CakePHP1.3でTreeビヘイビアを使用する時に、子ノードを取得するchildrenメソッド等の使用時に、lftやrght以外に条件を追加したい場合はModel上で$actAsを指定する際に以下のように指定すると取得条件が追加されるようです。

<?php
class Section extends AppModel {

    var $name = 'Section';

    var $actsAs = array( 'Tree' => array('scope' => 'status = 1') );

上記のように記載すると、Sectionテーブル内のstatusカラムの値が1のもののみが取得されるようになります。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0