Table of Contents

Class PageViewModelExtensions

Namespace
Dynamicweb.Frontend
Assembly
Dynamicweb.dll

Provides extension methods for the PageViewModel.

public static class PageViewModelExtensions
Inheritance
PageViewModelExtensions
Inherited Members

Methods

GetButtonStyle(PageViewModel?)

Gets the link to the css file with the area's button styles.

public static string? GetButtonStyle(this PageViewModel? pageViewModel)

Parameters

pageViewModel PageViewModel

Returns

string

E.g. /Files/System/Styles/Buttons/SwiftStyle.css

GetColorSchemeStyle(PageViewModel?)

Gets the link to the css file with the area's color scheme group.

public static string? GetColorSchemeStyle(this PageViewModel? pageViewModel)

Parameters

pageViewModel PageViewModel

Returns

string

E.g. /Files/System/Styles/ColorSchemes/SwiftStyle.css

Generates hreflang <link rel="alternate"> tags for the specified page view model and URL context.

public static string? GetHreflangLinks(this PageViewModel model, HrefLanguageMode mode = HrefLanguageMode.Mixed)

Parameters

model PageViewModel

The PageViewModel instance containing the page and its available language versions.

mode HrefLanguageMode

Determines how hreflang attributes are formatted. FullCulture uses the full language–region code (e.g. "de-de"), LanguageOnly uses only the language code (e.g. "de"), and Mixed automatically decides based on language duplication across regions.

Returns

string

A string containing a set of hreflang link elements for all published language versions of the page, including an x-default entry for the master area. Returns an empty string if no languages are defined.

This method uses UriBuilder to safely construct alternate URLs and ensures consistent schemes and hosts. It assumes Languages already contains only active and published languages.

The mode parameter controls the granularity of the hreflang attributes:

  • RegionOnly: Always output full locale codes, e.g. en-us.
  • LanguageOnly: Always output short language codes, e.g. en.
  • Mixed: Use the short code when the language is unique; use the full code when multiple regions share the same language.

GetTypographyStyle(PageViewModel?)

Gets the link to the css file with the area's typography.

public static string? GetTypographyStyle(this PageViewModel? pageViewModel)

Parameters

pageViewModel PageViewModel

Returns

string

E.g. /Files/System/Styles/Typography/SwiftStyle.css

TryGetButtonStyle(PageViewModel?, out string?)

Returns true if a button style is specified on the area and the link to the css is assigned to the passed out parameter.

public static bool TryGetButtonStyle(this PageViewModel? pageViewModel, out string? value)

Parameters

pageViewModel PageViewModel
value string

Returns

bool

true if the button style is found and the value will have a value of e.g. /Files/System/Styles/Typography/SwiftStyle.css, otherwise false and value will be null

TryGetColorSchemeStyle(PageViewModel?, out string?)

Returns true if a color scheme group is specified on the area and the link to the css is assigned to the passed out parameter.

public static bool TryGetColorSchemeStyle(this PageViewModel? pageViewModel, out string? value)

Parameters

pageViewModel PageViewModel
value string

Returns

bool

true if the color scheme is found and the value will have a value of e.g. /Files/System/Styles/ColorSchemes/SwiftStyle.css, otherwise false and value will be null

TryGetTypographyStyle(PageViewModel?, out string?)

Returns true if a typography is specified on the area and the link to the css is assigned to the passed out parameter.

public static bool TryGetTypographyStyle(this PageViewModel? pageViewModel, out string? value)

Parameters

pageViewModel PageViewModel
value string

Returns

bool

true if the typography is found and the value will have a value of e.g. /Files/System/Styles/Typography/SwiftStyle.css, otherwise false and value will be null

To top