This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Example use: | |
* | |
* $helper = $modules->get("RandomImages"); | |
* $image = $helper->getRandomImages(1,"images"); | |
* echo "<img src='{$image->size(150,0)->url}'>"; | |
*/ | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Example form using PW API | |
* | |
* A workaround to get fields display in a table | |
* Those fields are marked with a property added to the fields $field->tablerow | |
* | |
* Approach is to grab those fields after form is put together and maybe processed, | |
* loop each row and render out the fields along with possible errors and add it to a string variable $table | |
* while we remove the field from the form at the same time. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// ------------------------------ FORM Processing --------------------------------------- | |
$errors = null; | |
$success = false; | |
// helper function to format form errors | |
function showError($e){ | |
return "<p class='error'>$e</p>"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// front-end form example with multiple images upload | |
// add new page created on the fly and adding images | |
$message = ''; | |
if($input->post->submit){ | |
// tmp upload folder for additional security |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$out = ''; | |
// create a new form field (also field wrapper) | |
$form = $modules->get("InputfieldForm"); | |
$form->action = "./"; | |
$form->method = "post"; | |
$form->attr("id+name",'subscribe-form'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Sandfox\Model; | |
use \Sandfox\Model\ModelAbstract; | |
class Cat extends ModelAbstract | |
{ | |
/** | |
* Define data names and defaults here |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var el = ( function () { | |
var doc = document; | |
var directProperties = { | |
'class': 'className', | |
className: 'className', | |
defaultValue: 'defaultValue', | |
'for': 'htmlFor', | |
html: 'innerHTML', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// an immediate function | |
(function(){ | |
// code goes here | |
})(); | |
// a module with a public API returned | |
var MyModule = (function(){ | |
// this variable is private | |
var privateVariable = "I'm scoped to the module's internals!"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
There are three essential components for most flexibly interacting with CouchDB from node: | |
couch API documentation: | |
http://jpmens.net/2010/04/20/the-antepenultimate-couchdb-reference-card/ | |
http://www.couchbase.org/sites/default/files/uploads/all/documentation/couchbase-api.pdf | |
javascript HTTP library: | |
http://github.com/mikeal/request | |
javascript _changes feed consuming libaries (pick one): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head><title>Tiny CouchApp</title></head> | |
<body> | |
<h1>Tiny CouchApp</h1> | |
<form id="new_message"> | |
<label for="message">Message:</label> | |
<input type="text" name="message" value=""> | |
<p><input type="submit" value="Save →"></p> | |
</form> |