addPageTitleElement(compact('sourceField')); $this->addPageAliasElement('alias', $tableAlias, compact('sourceField')); $this->addElement('textarea', 'metaKeywords', ['label' => 'Meta Keywords', 'rows' => 3]); $this->addElement('textarea', 'metaDescription', ['label' => 'Meta Description', 'rows' => 3]); return $this; } public function addPageTitleElement(array $options = []) { $defaults = [ 'label' => 'Page Title', 'maxlength' => '255', 'description' => $this->translate('This information will show in the browser tab and in search results.') ]; if ($options['sourceField']) { $sourceFields = (array) $options['sourceField']; $labels = []; foreach ($sourceFields as $sourceField) { if (($element = $this->getElement($sourceField))) { $labels[] = $element->getLabel(); } } if ($labels) { $defaults['description'] .= ' ' . $this->translate('If you leave this field empty - the Page Title will be the same as') . ' ' . implode(' ' . $this->translate('and') . ' ', $labels); } unset($options['sourceField']); } $this->addElement('text', 'metaTitle', array_merge($defaults, $options)); return $this; } public function addPageAliasElement($name, $tableAlias, array $options = []) { $defaults = [ 'label' => 'Alias', 'required' => true, 'maxlength' => 200, 'sourceField' => 'title', 'aliasValidatorOptions' => [ 'table' => new Qs_Db_Table($tableAlias), 'column' => $name, 'currentId' => $this->_getData('id') ] ]; $this->addElement('pageAlias', $name, array_merge($defaults, $options)); return $this; } protected function translate($text) { if ($this->getTranslator()) { return $this->getTranslator()->translate($text); } return $text; } }