Coder Social home page Coder Social logo

johnulist / drafts-zuha-cakephp-plugin Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 1.0 160 KB

Attach this plugin to any model to enable revision version control of the records in that model. Useful for a way of saving blog posts, or web page drafts and revisions.

Home Page: http://zuha.com/

drafts-zuha-cakephp-plugin's Introduction

Drafts Plugin for Zuha & Cakephp

Mainly a behavior in the form of a plugin, that adds the ability to easily save draft versions of a record without editing the current version of a record. Used for things like editing blog posts or web pages, but saving changes which aren't ready for prime time just yet. Version 1

Installation

  1. Create a plugins folder called Drafts
  2. Put this plugin into that folder. (or git clone [email protected]:zuha/Drafts-Zuha-Cakephp-Plugin.git app/Plugin/Drafts)

Save Usage

# in your model
public $actsAs = array('Drafts.Draftable');

# in your view
echo $this->Form->input('Article.draft', array('value' => 1));
  1. In the model you want to use drafts with, attach the Drafts.Draftable Behavior
  2. The default settings should do most of the work, but if you need something custom change the settings during behavior attachment.
  3. When you save a record add a field called 'draft' and set it to 1. For example...
  4. Click save and instead of editing the article it will save a draft which you can then preview by going to the view and

View Usage

# in your controller
public function beforeFilter() {
	parent::beforeFilter();
	if (!empty($this->request->params['named']['draft'])) { 
		$this->Article->Behaviors->attach('Drafts.Draftable', array(
			'returnVersion' => $this->request->params['named']['draft'],
			));
	}
}
  1. In your controller add a beforeFilter method, similar to the above...
  2. Visit a url similar to http://example.com/articles/articles/view/3/draft:1
  3. It will return the results of the newest draft instead of the actual live version
  4. Visit a url similar to http://example/articles/articles/view/3/draft:4
  5. It will return the results of the fourth oldest draft instead of the actual live version
  6. If there are only 2 drafts, then it will return the oldest available instead of the fourth.

Configuration Options

  1. triggerField ... Change the name of the field you send in a form from 'draft', to whatever you want.
  2. foreignKeyName ... If you want to hard code something other than 'id' as the primary key.
  3. reviseDateField ... unused as of 4/15/2012, meant to be for rolling back to older versions via post data.
  4. conditions ... Set conditions so that viewing a draft only works with a filtered subset of records. (ie. Article.type = public)
  5. returnVersion ... a setting to choose which version is returned during the find

Callbacks

  1. None

Requirements

  • PHP version: PHP 5.3+
  • CakePHP version: 2.x Stable

Support

For support and feature request, please visit submit an issue through Github.com.

For more information about our Professional Web Design, Development, and Marketing Services please visit the Zuha Development Corporation website.

License

Copyright 2009-2012, RazorIT LLC

Licensed under GPLv3 Redistributions of files must retain the below copyright notice.

Copyright

Copyright 2009-2012 RazoIT LLC 8417 Oswego Rd. #121 Baldwinsville, NY 13027 http://razorit.com

drafts-zuha-cakephp-plugin's People

Contributors

codeblastr avatar

Watchers

 avatar  avatar

Forkers

buildrr

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.