Skip to content

Instantly share code, notes, and snippets.

View jbroadway's full-sized avatar

John de Plume jbroadway

View GitHub Profile
@jbroadway
jbroadway / loops.html
Created July 24, 2013 13:30
Looping examples in Elefant templates
<!-- apps/test/views/loops.html -->
<ul>
{% foreach my_array as my_key, my_value %}
<li>{{my_key}}. {{my_value}}</li>
{% end %}
</ul>
<hr />
@jbroadway
jbroadway / Info.md
Created June 25, 2013 17:08
Example of using Ratchet with Elefant

To install Ratchet, add the following line to the "require" section of the composer.json file found in the root of your Elefant site:

"cboden/Ratchet": "0.2.*"

The section should look like this:

"require": {
	"php": ">=5.3.2",
	"cboden/Ratchet": "0.2.*"
}
@jbroadway
jbroadway / embed.php
Created June 25, 2013 16:40
An example of a simple handler that's listed in Elefant's Dynamic Objects menu.
; <?php /* apps/myapp/conf/embed.php
[myapp/myhandler]
label = "MyApp: My Handler"
; */ ?>
@jbroadway
jbroadway / basic.html
Created May 29, 2013 17:30
Possible "basic" template for Elefant
<!DOCTYPE html>
<html>
<head>
<title>{{ window_title|none }}</title>
<meta charset="{{ i18n.charset }}" />
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Roboto:400,300" />
{% if detect('mobile') %}
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0" />
<link rel="stylesheet" type="text/css" href="/css/mobile.css" />
{% else %}
@jbroadway
jbroadway / Link.php
Last active December 14, 2015 12:38
Alternative link generation proposal for Elefant 2. Note that this also proposes changing line 370 of `lib/I18n.php` to `$this->prefix = '/' . $matches[1];` so that a prefix is set when a URL like `/en` is matched.
@jbroadway
jbroadway / multi-file.html
Created February 27, 2013 16:33
Selecting multiple files or images in an Elefant form.
<!-- apps/demo/views/multi-file.html -->
{! filemanager/util/multi-file !}
<script>
$(function () {
$.multi_file ({
field: '#files',
preview: '#preview'
});
@jbroadway
jbroadway / add.html
Created February 27, 2013 00:17
Multi-image selection demo in Elefant. Generate an app via `./elefant crud-app listing id name description images` and this replaces the add.html view.
{! filemanager/util/browser !}
<script>
$(function () {
// Get the image list from the hidden field
function get_images () {
var images = $('#images').val ();
if (images.length === 0) {
return [];
@jbroadway
jbroadway / file.html
Created February 25, 2013 17:49
File chooser in Elefant
<!-- apps/demo/views/file.html -->
{! filemanager/util/browser !}
<form method="post" id="{{_form}}">
<p>
<input type="text" name="file" id="file" value="{{file|quotes}}" />
<input type="submit" id="browse" value="{"Choose an file"}" />
</p>
@jbroadway
jbroadway / images.html
Created February 25, 2013 17:46
Image chooser with preview in form in Elefant
<!-- apps/demo/views/images.html -->
{! filemanager/util/browser !}
<form method="post" id="{{_form}}">
<p>
<input type="submit" id="browse" value="{"Choose an image"}" />
<input type="hidden" name="image" id="image" value="{{image|quotes}}" />
</p>
@jbroadway
jbroadway / yesno.html
Created February 25, 2013 16:04
Creating a yes/no select box form element in Elefant.
<!-- apps/demo/views/yesno.html -->
<form method="post" id="{{_form}}">
<p>
Yes/no:<br />
<select name="yesno">
<option value="yes"{% if yesno === 'yes' %} selected{% end %}>{"Yes"}</option>
<option value="no"{% if yesno === 'no' %} selected{% end %}>{"No"}</option>
</select>