Skip to content

Instantly share code, notes, and snippets.

View jbroadway's full-sized avatar

John de Plume jbroadway

View GitHub Profile
@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>
@jbroadway
jbroadway / wysiwyg.html
Created February 25, 2013 15:42
Using Elefant's wysiwyg editor in your own forms
<!-- apps/demo/views/wysiwyg.html -->
{! admin/util/wysiwyg !}
<textarea name="body" id="webpage-body" cols="90" rows="28">{{body}}</textarea>
@jbroadway
jbroadway / README.md
Created February 18, 2013 16:10
Form hook handler for Elefant form app.

Save the formhook.php file to apps/test/handlers/formhook.php then add this to the [Hooks] section of conf/config.php:

form/submitted[] = test/formhook

Create a form and enter a test submission through it on the website (I just embed it on a page with the Dynamic Objects > Embed a Form option in the wysiwyg editor). You should see something like the following in cache/_form_values_.txt:

{"form":"1","values":{"name":"Joe User","email":"joe@example.com","comments":"Testing."}}
@jbroadway
jbroadway / README.md
Last active December 13, 2015 18:18
Possible navigation/* changes to include /lang/ URL prefixes when negotiation_method = url

Similar to how class="current" is added after the nav list is generated, we may be able to check $i18n->url_includes_lang and inject the language prefixes in the same way. If we setup a menu structure like the following, this seems to work correctly for both top-level and section navigation:

  • English (en)
    • About (about)
    • Products (products)
  • Français (fr)
    • A propos (a-propos)
    • Produits (produits)

The navigation/top output then becomes:

@jbroadway
jbroadway / dynamic.js
Created February 11, 2013 19:17
A plugin for Redactor to integrate with the Elefant CMS's dynamic object embedding.
/**
* Provides a Dynamic Objects menu for the Redactor editor,
* which integrates with Elefant's dynamic handler embedding
* capability.
*/
if (typeof ReactorPlugins === 'undefined') var RedactorPlugins = {};
RedactorPlugins.dynamic = {
// Initialize the plugin
@jbroadway
jbroadway / README.md
Last active December 12, 2015 06:49
Poor man's admin ACL for Elefant CMS.

This will show/hide links in the Tools admin menu based on a custom user role field. Note that it doesn't prevent users from browsing to those links through other means.

To add it to your site:

  1. Log into Elefant and go to Tools > Users > Custom Fields. Add a Role drop down field and list all admin roles here.
  2. Save the tools.php file to apps/acl/handlers/tools.php.
  3. Edit the tools.html file to add your own roles and the links they can see, then save it to apps/acl/views/tools.html.
  4. Add this tag directly below the {! admin/head !} tag in each layout template, including layouts/admin.html: