Coder Social home page Coder Social logo

cdvrooman / tree_counter_cache Goto Github PK

View Code? Open in Web Editor NEW

This project forked from neilcrookes/tree_counter_cache

1.0 2.0 1.0 81 KB

CakePHP Behavior to cache the counts of all children (inc grand children etc) and direct children of nodes in your tree.

Home Page: http://www.neilcrookes.com/

tree_counter_cache's Introduction

TreeCounterCache

An extension to CakePHP's core TreeBehavior that provides counterCache functionality for all children and/or direct children of each node in the tree. Packaged as a plugin with a fixture and unit tests with 100% code coverage.

Usage

  1. Install the plugin from my github account in your APP/plugins directory.

  2. Add child_count and/or direct_child_count integer fields to your database table (you can configure the field names in the settings when you attach the behavior to the model).

  3. Attach the TreeCounterCache Behavior to your model:

Why?

Useful if you ever need to know whether a node has child nodes, e.g. for adding a CSS class to alter the style of that node to indicate to the user there is something beneath it. Caching the count saves extra db queries. To be honest, it's not that great really is it? Still, might be useful to someone.

Todo

  • Add counterScope functionality

tree_counter_cache's People

Stargazers

Christopher Vrooman avatar

Watchers

Christopher Vrooman avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.