Coder Social home page Coder Social logo

helpfulrobot / briceburg-silverstripe-flexilink Goto Github PK

View Code? Open in Web Editor NEW

This project forked from briceburg/silverstripe-flexilink

0.0 2.0 0.0 99 KB

Link to SiteTree Pages, External URLs, YouTube Videos, &c. from a single, flexible SilverStripe field.

PHP 90.79% CSS 0.91% JavaScript 8.30%

briceburg-silverstripe-flexilink's Introduction

silverstripe-flexilink

Link to SiteTree Pages, External URLs, YouTube Videos, &c. from a single, flexible SilverStripe field.

Requirements

SilverStripe 3+

Screenshots

flexichoice field

See silverstripe-flexichoice for a similar text input field.

Usage

  • Add FlexiLink field types to your DataObject(s)
class BlockContentHeading extends DataObject {
  private static $db = array(
    'Title'     => 'Varchar',
    'Content'   => 'Text',
    'Link'      => 'FlexiLink',   // <--- here
    'LinkText'  => 'FlexiChoice', 
  );
  

Trigger the environment builder (/dev/build) after extending objects -- You will now see the FlexiLinkField appear in the CMS when editing your object.

  • FlexiLink provides the following public template methods
<div class="block-heading">
  <h1>$Title</h1>
  $Content
  
  <% if Link.exists %>
    <div class="link">
  
    <% if Link.Type == 'YouTubeID' %>
      <a class="button" href="$Link.URL" target="_blank">WATCH <span>MOVIE</span></a>
    <% else %>
      <a class="button" href="$Link.URL">$LinkText</a>
    <% end_if %>
    
    </div>
  <% end_if %>
  
</div>
  • You may define link selection types and their related fields in YAML Configuration. Here's an example /mysite/config/_config.yml
---
Name: mysite
After:
  - 'framework/*'
  - 'cms/*'
---
# YAML configuration for SilverStripe
# See http://doc.silverstripe.org/framework/en/topics/configuration
# Caution: Indentation through two spaces, not tabs
SSViewer:
  theme: 'site'
  
FlexiLinkField:
  allowed_types:
    - Page
    - Google
    
  field_types:
    Google:
      field: TextField
      description: TestTest

This example adds a custom 'Google' field type, and limits the dropdown selection to 'Page' and 'Google' (hides the built-in YouTubeID and ExternalURL).

Remember, ?flush=all after YML configuration changes to register them in the manifest.

briceburg-silverstripe-flexilink's People

Contributors

briceburg 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.