> ## Documentation Index
> Fetch the complete documentation index at: https://dokumentation.websale.de/llms.txt
> Use this file to discover all available pages before exploring further.

# $wsViews - Retrieve current information

> Reference for $wsViews: access current page data, generate URLs and add SEO-friendly meta tags, hreflang and template-aware content to the shop.

With the `$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`

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
{{= $wsViews | json }}
```

**JSON output**

```json theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
{
  "current": {
    "closedShopRedirected": false,
    "ctrlName": "...",
    "info": { },
    "name": "...",
    "paramList": [...],
    "params": { },
    "robotOptions": [...],
    "status": 200,
    "getHreflangAutomatic": "ƒ()",
    "url": "ƒ()"
  },
  "host": "...",
  "getHreflangManual": "ƒ()",
  "identifyUrl": "ƒ()",
  "metaDescription": "ƒ()",
  "metaTitle": "ƒ()",
  "setChildUrl": "ƒ()",
  "url": "ƒ()",
  "viewUrl": "ƒ()"
}
```

Note: `ƒ()` 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.

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
{{= $wsViews.current | json }}
```

#### \$wsViews.current.ctrlName

Returns the name of the view controller that delivers the current page.

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
View controller: {{= $wsViews.current.ctrlName }}
```

#### \$wsViews.current.closedShopRedirected

Returns whether the user was redirected from a closed shop.

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
{{ if $wsViews.current.closedShopRedirected }}
  // Redirected from closed shop
{{ /if }}
```

#### \$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`).

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
Additional information: {{= $wsViews.current.info}}
```

#### \$wsViews.current.name

Returns the name of the current view.

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
{{ if $wsViews.current.name == "category.htm" }}
    // Category page
{{ /if }}
```

#### \$wsViews.current.paramList

Returns a list of URL parameters. Each entry contains `name` and `value`.

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
{{ foreach $myParam in $wsViews.current.paramList }}
  {{= $myParam.name }}: {{= $myParam.value }}
{{ /foreach }}
```

#### \$wsViews.current.params

Returns the URL parameters as a map.

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
{{ if $wsViews.current.params.promoCode }}
  Promo code: {{= $wsViews.current.params.promoCode }}
{{ /if }}
```

#### \$wsViews.current.robotOptions

Returns the robots settings of the page.

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
Robots: {{= $wsViews.current.robotOptions | json }}
```

#### \$wsViews.current.status

Returns the HTTP status code of the page.

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
Status: {{= $wsViews.current.status }}
```

### \$wsViews.host

Returns the URL of the shop's home page.

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
Shop home page: {{= $wsViews.host }}
```

***

## 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 value**\
`string` - Current URL / path.

**Example** that outputs the current URL.

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
Current URL: {{= $wsViews.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.

**Signature**\
`string $wsViews.url(viewCtrl, params)`

**Return value**\
`string` *-* 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**\
Example that generates a URL to a product page.

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
{{= $wsViews.url('Product', {productId: $cProduct.product.id}) }}
```

**Return example:**

```text theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
/produkte/beispiel-produkt-12345
```

### \$wsViews.viewUrl()

Generates a URL to a template file.

**Signature**

`string wsViews.viewUrl(path, params, type)`

**Return value**\
`string` - 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"`).                                 |

**Example** that generates a URL to the forgot-password page:

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
<a href="{{= $wsViews.viewUrl('account/forgotPassword.htm') }}">
  Forgot password?
</a>
```

### \$wsViews.metaTitle()

Returns the page title for the browser tab and search results.

**Signature**\
`string $wsViews.metaTitle()`

**Return value**\
`string` - Page title.

**Example** that sets the meta title in the HTML head:

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
<title>{{= $wsViews.metaTitle() }}</title>
```

### \$wsViews.metaDescription()

Returns the page description for search results.

**Signature**\
`string $wsViews.metaDescription()`

**Return value**\
`string` - Page description.

**Example** that sets the meta description in the HTML head.

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
<meta name="description" content="{{= $wsViews.metaDescription() }}">
```

### \$wsViews.getHreflangManual()

Returns manually configured `hreflang` entries.

**Signature**\
`$wsViews.getHreflangManual()`

**Return value**\
`array` - List of manual language versions.

**Example** that outputs manual `hreflang` links.

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
{{ foreach $myHref in $wsViews.getHreflangManual() }}
  <link rel="alternate" hreflang="{{= $myHref.lang }}" href="{{= $myHref.href }}">
{{ /foreach }}
```

### \$wsViews.current.getHreflangAutomatic()

Returns the language versions of the current page for hreflang tags.

**Signature**\
`$wsViews.current.getHreflangAutomatic()`

**Return value**\
`array` - List of language versions (`lang`, `href`).

**Example** that outputs automatic hreflang links.

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
{{ foreach $myHreflang in $wsViews.current.getHreflangAutomatic() }}
  <link rel="alternate" hreflang="{{= $myHreflang.lang }}" href="{{= $myHreflang.href }}">
{{ /foreach }}
```

***

## Actions

No actions are available for `$wsViews`.

***

## Examples for URL and parameter access

### View URL & host

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
<link rel="canonical" href="{{= $wsViews.host }}{{= $wsViews.current.url() }}" />

{{= $wsViews.current.url() }}
```

### Template-conditional content output

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
...
{{ if ($wsViews.current.name == "start") }}
  
  <section class="hero">…</section>
{{ /if }}
...
```

### Reading parameters (list & specific query)

Iteration over all parameters:

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
...
<ul class="params">
  {{ for (p in $wsViews.paramList) }}
    <li>{{= p.name }} = {{= p.value }}</li>
  {{ end }}
</ul>
...
```

Specific check (example "otp"):

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
{{ if ($wsViews.params.otp && $wsViews.params.otp == "required") }}
  <div class="notice notice--otp">Please enter the one-time password.</div>
{{ /if }}
```

### Hreflang & meta (short examples)

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
...
<title>{{= $wsViews.metaTitle() }}</title>
<meta name="description" content="{{= $wsViews.metaDescription() }}" />

{{ for (h in $wsViews.getHreflangAutomatic()) }}
  <link rel="alternate" hreflang="{{= h.lang }}" href="{{= h.href }}" />
{{ end }}

{{ for (h in $wsViews.getHreflangManual()) }}
  <link rel="alternate" hreflang="{{= h.lang }}" href="{{= h.href }}" />
{{ end }}
...
```

***

## Related links

* [Configure SEO metadata](/en/konfiguration/seometadata-meta-daten-seo-texte)
