$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
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
Example
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
Example that generates a URL to the forgot-password page:
$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.
