Meta data
Used to easly create and overwrite dynamic HTML meta data.
Class meta
- Name: meta
- Namespace: modular\meta
- Construct:
- String: Seperator (defualt: |) (required)
- Array: Titles
- String: Description
- Dependencies: modular\dom\document
Example
// Set and modify meta title $this->modal()->meta()->setTitle("Creative Army"); $this->modal()->meta()->prepend("About us"); // Set meta description $this->modal()->meta()->setDescription("Lorem ipsum dolor sit amet"); // Set meta canonical link $url = $this->modal()->url()->select('pages')->url(); $this->modal()->meta()->setCanonical($url); // Create a custom meta tag (other: setTitleDOM, setMetaDOM, setLinkDOM) $this->modal()->meta()->setMetaDOM("og:description", "Facebook meta description lorem ipsum dolor sit amet"); echo $this->modal()->meta()->html();
Result
<title>About us | Creative Army</title> <meta name="Description" content="Lorem ipsum dolor sit amet"> <link rel="canonical" href="https://example.com/about-us"> <meta property="og:description" content="Facebook meta description lorem ipsum dolor sit amet">
Method list
WA meta
Version: 3.0
Copyright: All right reserved for Creative Army
Set defaults meta values
@param string $sep How should title array items seperate when returned
@param array $title default title
@param string $description default description
__construct(string $sep, array $title = [], string $description = "")
Read/return the title
@param string
title()
Set the title. Will restart the array.
@param self
setTitle(array $add)
Prepend to title array
@param self
prepend($add)
Append to title array
@param self
append($add)
Read/return the description
@param string
description()
Set the description
@param self
setDescription(?string $add)
Read/return the canonical
@param string
canonical()
Set Canonical link
@param self
setCanonical(string $str)
Create custom "link" DOM tag
@param string $type (Link or Meta)
@return modular\dom\element
setLinkDOM(string $key, string $rel, bool $prepend = false)
Create custom "title" DOM tag
@param string $type (Link or Meta)
@return modular\dom\element
setTitleDOM(string $value, bool $prepend = false)
Create custom "meta" DOM tag
@param string $name (example: "Description")
@return modular\dom\element
setMetaDOM(string $name, bool $prepend = false)
Read process, execute and the read as meta-data ad HTML-code
@return string
html()