Coder Social home page Coder Social logo

fieldtypeselectfile's Introduction

FieldtypeSelectFile & InputfieldSelectFile

Inputfield Select File is an Inputfield & Fieldtype to select a single file or folder and stores the name and / or use the selected file as page template. The last option enables the editor to use multiple views for a page, depending on the selected template.

Settings

  • The folder containing the files and/or folders.

    • A relative path relative to the /site/templates/ folder.
  • Hide file extensions

  • Hide PHP File Description

    • PHP files can have a comment called "Description" at the top of the file which will be displayed in the dropdown if it exists. Check this option to disable it.
  • Hide files

  • Hide folders

  • Natural Sort (Select options)

    • Sort files and folders in natural ordering
  • Change Page Template

    • Just before the Page::loaded event the selected file is set as template file for the page. This setting can only be applied once per a page and folders are exluded from the select inputfield.

    Note that a page with no associated template file will render with the selected file.

When to use ?

Let editors select a file and base your own logic upon this. With the change page template setting you're able to use the selected file as template file. This could reduce the amount of normal templates needed and let editors choose how the page get rendered. This field is real good companion with InputfieldSelector, there are plenty of use cases for this Inputfield.

In the examples I call the field selected_file.

// let the editor choose a CSS file
$config->scripts->append($config->urls->templates . "scripts/" . $page->selected_file);

/**
 * advanced usage example
 *
 * You need multiple ways to render your markup. Let the site editor choose which
 * file the page need to render.
 *
 */

$tpl = new TemplateFile($config->paths->templates . "includes/" . $page->selected_file);
$tpl->set('current', $page);
$markup = $tpl->render();

fieldtypeselectfile's People

Contributors

da-fecto avatar

Stargazers

 avatar Jonathan Lahijani avatar Marcus Herrmann avatar

Watchers

James Cloos avatar  avatar

Forkers

lisandi nuesse

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.