SilverStripe Link

Link extends DataObject

Link

Tags
subpackage

silverstripe-link

mixin

LinkSiteTree

Table of Contents

Properties

$classes  : string
$template_style  : string
$allowed_types  : array<string|int, mixed>
List the allowed included link types. If null all are allowed.
$casting  : array<string|int, mixed>
Ensures that the methods are wrapped in the correct type and values are safely escaped while rendering in the template.
$db  : array<string|int, mixed>
Database fields
$gql_fields  : mixed
Provides a quick way to define additional methods for provideGraphQLScaffolding as Fields
$gql_nested_queries  : array<string|int, mixed>
Provides a quick way to define additional methods for provideGraphQLScaffolding as Nested Queries
$has_one  : array<string|int, mixed>
Has_one relationship
$link_to_folders  : bool
If false, when Type is "File", folders in the TreeDropdownField will not be selectable.
$linking_mode_current  : string
$linking_mode_default  : string
$linking_mode_section  : string
$owns  : mixed
$searchable_fields  : array<string|int, mixed>
Defines a default list of filters for the search context
$styles  : array<string|int, mixed>
A map of styles that are available in the cms for users to select from.
$summary_fields  : array<string|int, mixed>
Defines summary fields commonly used in table columns as a quick overview of the data for this dataobject
$table_name  : string
Defines the database table name
$types  : array<string|int, mixed>
A map of object types that can be linked to Custom dataobjects can be added to this

Methods

addExtraClass()  : Link
Set CSS classes for templates
baseClassName()  : string
Returns the base class without namespacing
canCreate()  : bool
canDelete()  : bool
canEdit()  : bool
canView()  : bool
File()  : File
forTemplate()  : DBHTMLText
Renders an HTML anchor attribute for this link
getClass()  : string
Returns the css classes
getClassAttr()  : HTMLFragment
Returns the html class attribute
getCMSFields()  : FieldList
CMS Fields
getCMSMainFields()  : array<string|int, mixed>
CMS Main fields This is so other modules can access these fields without other tabs etc.
getCurrentPage()  : Controller
Returns the current page scope
geti18nStyles()  : array<string|int, mixed>
Returns available styles with translations
geti18nTypes()  : array<string|int, mixed>
Returns allowed link types with translations
getIDAttr()  : HTMLFragment
Renders an HTML ID attribute
getIDValue()  : string
Returns the html id attribute
getLayout()  : string
Renders an HTML anchor tag for this link This is an alias to {@link forTemplate()}
getLinkURL()  : string
Works out what the URL for this link should be based on it's Type
getRenderTemplates()  : array<string|int, mixed>
Returns a list of rendering templates
getStyle()  : Link
Get style defined by the template or admin
getStyles()  : array<string|int, mixed>
Returns available styles
getTarget()  : string
Returns the html target attribute
getTargetAttr()  : HTMLFragment
Returns the html target attribute
getTypeLabel()  : string
Returns the description label of this links type
getTypes()  : array<string|int, mixed>
Returns allowed link types
gqlFields()  : array<string|int, mixed>
Provides a quick way to define additional methods to provideGraphQLScaffolding as Fields
gqlNestedQueries()  : array<string|int, mixed>
Provides a quick way to define additional methods to provideGraphQLScaffolding as Nested Queries
isCurrent()  : bool
Returns true if this is the currently active page being used to handle this request.
isOrphaned()  : bool
Check if the parent of this page has been removed (or made otherwise unavailable), and is still referenced by this child. Any such orphaned page may still require access via the CMS, but should not be shown as accessible to external users.
isSection()  : bool
Check if this page is in the currently active section (e.g. it is either current or one of its children is currently being viewed).
LinkingMode()  : string
Return "link", "current" or "section" depending on if this page is the current page, or not on the current page but in the current section.
LinkOrCurrent()  : string
Return "link" or "current" depending on if this is the {@link Link::isCurrent()} current page.
LinkOrSection()  : string
Return "link" or "section" depending on if this is the {@link Link::isSection()} current section.
onBeforeWrite()  : mixed
Event handler called before writing to the database.
setAllowedTypes()  : Link
Sets allowed link types
setClass()  : Link
This is an alias to {@link addExtraClass()}
setStyle()  : Link
Set style used for
validate()  : ValidationResult
Validate

Properties

$classes

protected string $classes = []

custom CSS classes for template

$template_style

protected string $template_style

custom style for template typically defined by the template.

$allowed_types

List the allowed included link types. If null all are allowed.

private static array<string|int, mixed> $allowed_types = null

$casting

Ensures that the methods are wrapped in the correct type and values are safely escaped while rendering in the template.

private static array<string|int, mixed> $casting = ['ClassAttr' => 'HTMLFragment', 'TargetAttr' => 'HTMLFragment', 'IDAttr' => 'HTMLFragment']

$db

Database fields

private static array<string|int, mixed> $db = ['Title' => 'Varchar', 'Type' => 'Varchar(50)', 'URL' => 'Text', 'Email' => 'Varchar', 'Phone' => 'Varchar(30)', 'OpenInNewWindow' => 'Boolean', 'SelectedStyle' => 'Varchar']

$gql_fields

Provides a quick way to define additional methods for provideGraphQLScaffolding as Fields

private static mixed $gql_fields = []

$gql_nested_queries

Provides a quick way to define additional methods for provideGraphQLScaffolding as Nested Queries

private static array<string|int, mixed> $gql_nested_queries = []

$has_one

Has_one relationship

private static array<string|int, mixed> $has_one = ['File' => \SilverStripe\Assets\File::class]

If false, when Type is "File", folders in the TreeDropdownField will not be selectable.

private static bool $link_to_folders = false
Tags
config

$linking_mode_current

private static string $linking_mode_current = 'current'
Tags
config

$linking_mode_default

private static string $linking_mode_default = 'link'
Tags
config

$linking_mode_section

private static string $linking_mode_section = 'section'
Tags
config

$owns

private static mixed $owns = ['File']

$searchable_fields

Defines a default list of filters for the search context

private static array<string|int, mixed> $searchable_fields = ['Title', 'URL', 'Email', 'Phone']

$styles

A map of styles that are available in the cms for users to select from.

private static array<string|int, mixed> $styles = []

$summary_fields

Defines summary fields commonly used in table columns as a quick overview of the data for this dataobject

private static array<string|int, mixed> $summary_fields = ['Title' => 'Title', 'TypeLabel' => 'Type', 'LinkURL' => 'Link']

$table_name

Defines the database table name

private static string $table_name = 'Link'

$types

A map of object types that can be linked to Custom dataobjects can be added to this

private static array<string|int, mixed> $types = ['URL' => 'URL', 'Email' => 'Email address', 'Phone' => 'Phone number', 'File' => 'File on this website']

Methods

addExtraClass()

Set CSS classes for templates

public addExtraClass(string $class) : Link
Parameters
$class : string

CSS classes.

Return values
Link

baseClassName()

Returns the base class without namespacing

public baseClassName(string $class) : string
Parameters
$class : string
Return values
string

canCreate()

public canCreate([Member|null $member = null ][, array<string|int, mixed> $context = [] ]) : bool
Parameters
$member : Member|null = null
$context : array<string|int, mixed> = []
Return values
bool

canDelete()

public canDelete([Member|null $member = null ]) : bool
Parameters
$member : Member|null = null
Return values
bool

canEdit()

public canEdit([Member|null $member = null ]) : bool
Parameters
$member : Member|null = null
Return values
bool

canView()

public canView([Member|null $member = null ]) : bool
Parameters
$member : Member|null = null
Return values
bool

File()

public File() : File
Return values
File

forTemplate()

Renders an HTML anchor attribute for this link

public forTemplate() : DBHTMLText
Return values
DBHTMLText

getClass()

Returns the css classes

public getClass() : string
Return values
string

getClassAttr()

Returns the html class attribute

public getClassAttr() : HTMLFragment
Return values
HTMLFragment

getCMSFields()

CMS Fields

public getCMSFields() : FieldList
Return values
FieldList

getCMSMainFields()

CMS Main fields This is so other modules can access these fields without other tabs etc.

public getCMSMainFields() : array<string|int, mixed>
Return values
array<string|int, mixed>

getCurrentPage()

Returns the current page scope

public getCurrentPage() : Controller
Return values
Controller

geti18nStyles()

Returns available styles with translations

public geti18nStyles() : array<string|int, mixed>
Return values
array<string|int, mixed>

geti18nTypes()

Returns allowed link types with translations

public geti18nTypes() : array<string|int, mixed>
Return values
array<string|int, mixed>

getIDAttr()

Renders an HTML ID attribute

public getIDAttr() : HTMLFragment
Return values
HTMLFragment

getIDValue()

Returns the html id attribute

public getIDValue() : string
Return values
string

getLayout()

Renders an HTML anchor tag for this link This is an alias to {@link forTemplate()}

public getLayout() : string
Return values
string

getLinkURL()

Works out what the URL for this link should be based on it's Type

public getLinkURL() : string
Return values
string

getRenderTemplates()

Returns a list of rendering templates

public getRenderTemplates() : array<string|int, mixed>
Return values
array<string|int, mixed>

getStyle()

Get style defined by the template or admin

public getStyle() : Link
Return values
Link

getStyles()

Returns available styles

public getStyles() : array<string|int, mixed>
Return values
array<string|int, mixed>

getTarget()

Returns the html target attribute

public getTarget() : string
Return values
string

getTargetAttr()

Returns the html target attribute

public getTargetAttr() : HTMLFragment
Return values
HTMLFragment

getTypeLabel()

Returns the description label of this links type

public getTypeLabel() : string
Return values
string

getTypes()

Returns allowed link types

public getTypes() : array<string|int, mixed>
Return values
array<string|int, mixed>

gqlFields()

Provides a quick way to define additional methods to provideGraphQLScaffolding as Fields

public gqlFields() : array<string|int, mixed>
Return values
array<string|int, mixed>

gqlNestedQueries()

Provides a quick way to define additional methods to provideGraphQLScaffolding as Nested Queries

public gqlNestedQueries() : array<string|int, mixed>
Return values
array<string|int, mixed>

isCurrent()

Returns true if this is the currently active page being used to handle this request.

public isCurrent() : bool
Return values
bool

isOrphaned()

Check if the parent of this page has been removed (or made otherwise unavailable), and is still referenced by this child. Any such orphaned page may still require access via the CMS, but should not be shown as accessible to external users.

public isOrphaned() : bool
Return values
bool

isSection()

Check if this page is in the currently active section (e.g. it is either current or one of its children is currently being viewed).

public isSection() : bool
Return values
bool

LinkingMode()

Return "link", "current" or "section" depending on if this page is the current page, or not on the current page but in the current section.

public LinkingMode() : string
Return values
string

LinkOrCurrent()

Return "link" or "current" depending on if this is the {@link Link::isCurrent()} current page.

public LinkOrCurrent() : string
Return values
string

LinkOrSection()

Return "link" or "section" depending on if this is the {@link Link::isSection()} current section.

public LinkOrSection() : string
Return values
string

onBeforeWrite()

Event handler called before writing to the database.

public onBeforeWrite() : mixed

If the title is empty, set a default based on the link.

setAllowedTypes()

Sets allowed link types

public setAllowedTypes([array<string|int, mixed> $types = [] ]) : Link
Parameters
$types : array<string|int, mixed> = []

Allowed type names

Return values
Link

setClass()

This is an alias to {@link addExtraClass()}

public setClass(string $class) : Link
Parameters
$class : string

CSS classes.

Return values
Link

setStyle()

Set style used for

public setStyle(string $style) : Link
Parameters
$style : string
Return values
Link

validate()

Validate

public validate() : ValidationResult
Return values
ValidationResult

        
On this page

Search results