public function output(\Pagemill_Data $data, \Pagemill_Stream $stream) { $this->_hasTitle = false; $this->_hasMetaDescription = false; $this->_hasMetaKeywords = false; $this->_recurseThroughChildren($this); if (!$this->_hasTitle) { new Typeframe_Tag_Seo_Title('title', array(), $this); } if (!$this->_hasMetaDescription) { new Typeframe_Tag_Seo_Meta('meta', array('name' => 'description'), $this); } if (!$this->_hasMetaKeywords) { new Typeframe_Tag_Seo_Meta('meta', array('name' => 'keywords'), $this); } $urlmeta = Model_UrlMeta::GetUrl(null, false); $tag = null; if ($urlmeta->exists()) { $seo = Model_SeoHead::Get($urlmeta['id']); if ($seo->exists()) { if ($seo['extra']) { $fragment = new Pagemill_Node_Frag($this->doctype()); $fragment->appendRawText($seo['extra']); $this->appendChild($fragment); } } } parent::output($data, $stream); // TODO: Do we need to detach the fragment? }
public function output(\Pagemill_Data $data, \Pagemill_Stream $stream) { if ($this->getAttribute('name') == 'keywords') { $name = 'keywords'; } else { if ($this->getAttribute('name') == 'description') { $name = 'description'; } else { parent::output($data, $stream); return; } } $urlmeta = Model_UrlMeta::GetUrl(null, false); if (!$urlmeta->exists()) { parent::output($data, $stream); return; } $seo = Model_SeoHead::Get($urlmeta['id']); if (!$seo->exists()) { parent::output($data, $stream); return; } if (!$seo['meta' . $name]) { parent::output($data, $stream); return; } $meta = new Pagemill_Tag('meta', $this->attributes, null, $this->doctype()); $meta->setAttribute('content', $seo['meta' . $name]); $meta->output($data, $stream); }
protected function output(\Pagemill_Data $data, \Pagemill_Stream $stream) { $urlmeta = Model_UrlMeta::GetUrl(null, false); if (!$urlmeta->exists()) { parent::output($data, $stream); return; } $seo = Model_SeoHead::Get($urlmeta['id']); if (!$seo->exists()) { parent::output($data, $stream); return; } if (!$seo['title']) { parent::output($data, $stream); return; } $title = new Pagemill_Tag_AlwaysExpand('title', $this->attributes(), null, $this->doctype()); $title->appendText($seo['title']); $title->output($data, $stream); }
<?php if ($_REQUEST['url']) { $parts = parse_url($_REQUEST['url']); $urlmeta = Model_UrlMeta::GetUrl($parts['path']); if (!$urlmeta->exists()) { Typeframe::Redirect('Invalid page specified: ' . $_REQUEST['url'], Typeframe::CurrentPage()->applicationUri(), -1); return; } $head = Model_SeoHead::Get($urlmeta['id']); if ($_SERVER['REQUEST_METHOD'] == 'POST') { $head['title'] = $_POST['title']; $head['metakeywords'] = $_POST['metakeywords']; $head['metadescription'] = $_POST['metadescription']; $head['extra'] = $_POST['extra']; $head->save(); Typeframe::Redirect('Title and meta content updated.', Typeframe::CurrentPage()->applicationUri()); return; } $pm->setVariable('urlmeta_path', $parts['path']); $pm->setVariable('seo', $head); } else { Typeframe::Redirect('No page specified.', Typeframe::CurrentPage()->applicationUri(), -1); }