2017 © Pedro Peláez
 

silverstripe-module linkfield

SilverStripe Link Field

image

iqnection-modules/linkfield

SilverStripe Link Field

  • Tuesday, December 26, 2017
  • by iqmeckert
  • Repository
  • 3 Watchers
  • 0 Stars
  • 90 Installations
  • PHP
  • 5 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 6 Versions
  • 3 % Grown

The README.md

Link Field

Works just like the RedirectorPage URL/Page field Provides and interface for creating an internal or external link. Internal link provides a TreeDropdownField for selecting a page within the site tree External provides a text field for entering the full URL Also provides availability to store opening in a new tab, (*1)

Requirements

Silverstripe 4+, (*2)

Install

composer require iqnection-modules/linkfield, (*3)

Usage

private static $db = array(
    'LinkedPage' => 'Link'
);

In your forms (CMS only)

$fields->push( IQnection\LinkField\LinkField::create($name,$title) );

setValue() expects either an array or serialized array of the following:, (*4)

array(
    'Location' => string ['Internal' | 'External'] (required)
    'Internal' => int [SiteTree Page ID]
    'External' => string [external URL | null],
    'NewTab' => [bool]
);

In your templates

<a href="$LinkedPage">Link Text</a>

DB class methods

URL

the raw entered URL for External, or $Page->Link() for internal, (*5)

AbsoluteURL

an absolute URL for external (adds http://), or $Page->AbsoluteLink() for internal, (*6)

LinkedPage

for internal only, returns the linked page SiteTree object, (*7)

forTemplate

returns URL(), (*8)

IsExternal

returns bool, if the link is external, (*9)

Location

returns string, the location set as either Internal or External, (*10)

Target

returns _blank or self for use in a target HTML attribute, (*11)

TargetATT(force=false)

returns a full target attribute, for new tab only [target="_blank"] pass $force=true to return attribute for both new tab and same tab, (*12)

The Versions

26/12 2017

dev-master

9999999-dev

SilverStripe Link Field

  Sources   Download

BSD-3-Clause

The Requires

 

module pages iqnection

26/12 2017

2.0.1

2.0.1.0

SilverStripe Link Field

  Sources   Download

BSD-3-Clause

The Requires

 

module iqnection

11/12 2017

2.0.0

2.0.0.0

SilverStripe Link Field

  Sources   Download

BSD-3-Clause

The Requires

 

module iqnection

21/09 2017

0.0.1.1

0.0.1.1

SilverStripe 3 Link Field

  Sources   Download

The Requires

 

pages iqnection

21/09 2017

1.0.x-dev

1.0.9999999.9999999-dev

SilverStripe 3 Link Field

  Sources   Download

The Requires

 

pages iqnection

26/08 2016

0.0.1

0.0.1.0

SilverStripe 3 Link Field

  Sources   Download

The Requires

 

pages iqnection