$wsViews module, you can access information about the current page and generate URLs to other shop pages. Typical use cases are SEO optimization (meta tags, hreflang), navigation, and conditional content based on the current template. In this section, you will learn how to access page data and generate SEO-friendly URLs.
Module overview
Example / excerpt of$wsViews
ƒ() denotes a function.
Variables and methods overview
| Name | Return type | Description |
|---|---|---|
current | map | Information about the current page. |
closedShopRedirected | bool | Checks whether a redirect from a closed shop has occurred. |
ctrlName | string | Name of the view controller. |
getHreflangAutomatic | function | Returns the values of the hreflang tags of the current page. |
info | map | Additional info from the controller (e.g. category, product). |
name | string | Name of the view file (e.g. "start.htm"). |
paramList | array | List of URL parameters with name and value. |
name | string | Name of the parameter. |
value | string | Value of the parameter. |
params | map | URL parameters as a map ({name: value}). |
robotOptions | map | Robots settings of the page. |
status | number | HTTP status code (e.g. 200). |
host | string | Returns the URL of the home page. |
metaDescription | string | Meta description of the current page, page description. |
metaTitle | string | Meta title of the current page; page title. |
url | string | Returns the currently accessed URL. |
viewUrl | string | Builds a URL to a view using the specification of a view controller and its parameters. |
current.url() | string | Generates an SEO-friendly URL to a shop page. |
url() | string | Builds a link to a shop page. |
viewUrl() | string | Generates a URL to a template file. |
metaTitle() | string | Returns the page title for the browser tab and search results. |
metaDescription() | string | Returns the page description for search results. |
getHreflangManual() | array | Returns manually configured hreflang entries. |
current.getHreflangAutomatic() | array | Returns the language versions of the current page for hreflang tags. |
Variables
$wsViews.current
Contains all information about the currently displayed page.$wsViews.current.ctrlName
Returns the name of the view controller that delivers the current page.$wsViews.current.closedShopRedirected
Returns whether the user was redirected from a closed shop.$wsViews.current.info
Returns context-specific data, e.g. the current product on product pages (info.product) or the category on category pages (info.category).
$wsViews.current.name
Returns the name of the current view.$wsViews.current.paramList
Returns a list of URL parameters. Each entry containsname and value.
$wsViews.current.params
Returns the URL parameters as a map.$wsViews.current.robotOptions
Returns the robots settings of the page.$wsViews.current.status
Returns the HTTP status code of the page.$wsViews.host
Returns the URL of the shop’s home page.Methods
$wsViews.current.url()
Generates an SEO-friendly URL to a shop page. The URL is automatically generated with descriptive paths (e.g./produkte/beispiel-produkt instead of ?productId=123).
Signature$wsViews.current.url()
Return valuestring - Current URL / path.
Example that outputs the current URL.
$wsViews.url()
Builds a link to a shop page (e.g. product page, category page). The URL is automatically generated in SEO-friendly format. Signaturestring $wsViews.url(viewCtrl, params)
Return valuestring - URL/path to the desired page.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
viewCtrl | string | yes | Target controller / page type (e.g. Product, Category) |
params | map | yes | Parameters to supplement/override the URL; the value null removes a parameter. |
Example that generates a URL to a product page.
$wsViews.viewUrl()
Generates a URL to a template file. Signaturestring wsViews.viewUrl(path, params, type)
Return valuestring - URL to the specified view.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
path | string | yes | Path to the template file, e.g. account/forgotPassword.htm. |
params | map | no | Additional parameters for the URL. |
type | string | no | URL type (e.g. "absolute"). |
$wsViews.metaTitle()
Returns the page title for the browser tab and search results. Signaturestring $wsViews.metaTitle()
Return valuestring - Page title.
Example that sets the meta title in the HTML head:
$wsViews.metaDescription()
Returns the page description for search results. Signaturestring $wsViews.metaDescription()
Return valuestring - Page description.
Example that sets the meta description in the HTML head.
$wsViews.getHreflangManual()
Returns manually configuredhreflang entries.
Signature$wsViews.getHreflangManual()
Return valuearray - List of manual language versions.
Example that outputs manual hreflang links.
$wsViews.current.getHreflangAutomatic()
Returns the language versions of the current page for hreflang tags. Signature$wsViews.current.getHreflangAutomatic()
Return valuearray - List of language versions (lang, href).
Example that outputs automatic hreflang links.
Actions
No actions are available for$wsViews.
