Coder Social home page Coder Social logo

helpfulrobot / stephenjcorwin-silverstripe-icons Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 468 KB

SilverStripe module which provides an `Icon` DataObject and a `Settings->Appearance->Icons` Menu for managing your website's `Icons`.

License: BSD 3-Clause "New" or "Revised" License

PHP 4.28% Scheme 0.33% Ruby 0.07% CSS 95.32%

stephenjcorwin-silverstripe-icons's Introduction

silverstripe-icons

Introduction

SilverStripe module which provide a Icon DataObject and a Settings->Appearance->Icons Menu for managing your website's Icons.

Maintainer Contact

Requirements

  • SilverStripe 3.1

Related

Features

  • Create and maintain sitewide Icons

Installation

Installation can be done either by composer or by manually downloading a release.

####Via Composer: composer require stephenjcorwin/silverstripe-icons

####Manually:

  1. Download the module from the releases page
  2. Extract the file
  3. Make sure the folder after being extracted is name silverstripe-icons
  4. Place this directory in your site's root directory

####Configuration:

  • After installation, make sure you rebuild your database through dev/build
  • You should see the a new Menu in the CMS for managing Icons available through the Menu Settings->Appearance->Icons

Uninstall

####Via Composer: composer remove stephenjcorwin/silverstripe-icons

####Manually:

  1. Remove the silverstripe-icons directory in your site's root directory

####Configuration:

  • After uninstalling, make sure you rebuild your database through dev/build

Code Examples

####Defining a has_one relationship with Icon:

####mysite/code/MyDataObject.php <?php class MyDataObject extends DataObject { private static $has_one = array ( 'MyIcon' => 'Icon' );

    public function getCMSFields() {
        $fields = parent::getCMSFields();

        /*
        *   MAIN TAB
        */

        $tab = 'Root.Main';
        
        //provides listbox field menu for selecting a predefined Icon
        $data = DataObject::get('Icon');
        $field = new ListboxField('MyIconID', 'My Icon');
	    $field->setSource($data->map('ID', 'Name')->toArray());
	    $field->setEmptyString('Select one');
	    $fields->addFieldToTab($tab, $field);

        return $fields;
	}
}

####Using the Icon in your templates:

####mysite/code/Page.php <?php class Page extends SiteTree { private static $has_one = array( 'MyIcon' => 'Icon' );

	public function getCMSFields() {
        $fields = parent::getCMSFields();

        /*
        *   MAIN TAB
        */

        $tab = 'Root.Main';
        
        //provides listbox field menu for selecting a predefined Icon
        $data = DataObject::get('Icon');
        $field = new ListboxField('MyIconID', 'My Icon');
	    $field->setSource($data->map('ID', 'Name')->toArray());
	    $field->setEmptyString('Select one');
	    $fields->addFieldToTab($tab, $field);

        return $fields;
	}
}

class Page_Controller extends ContentController {
	public function init() {
		parent::init();
	}
}

####themes/mytheme/templates/Page.ss <% if $MyIcon %> <% with $MyIcon %><% include Icon %><% end_with %> <% end_if %> $Layout

stephenjcorwin-silverstripe-icons's People

Contributors

stephencorwin avatar

Watchers

James Cloos avatar helpfulrobot avatar

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.