Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions Classes/BackendModule/SeoModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ public function main() {
$tree->addField('keywords', 1);
$tree->addField('description', 1);
$tree->addField('tx_realurl_pathsegment', 1);
$tree->addField('tx_seo_priority', 1);
$tree->init('AND '.$GLOBALS['BE_USER']->getPagePermsClause(1));


Expand Down Expand Up @@ -262,6 +263,7 @@ protected function renderSEOTable($tree) {
$item['keywords'] = $translations[$this->langOnly]['keywords'];
$item['description'] = $translations[$this->langOnly]['description'];
$item['sys_language'] = $this->langOnly;
$item['tx_seo_priority'] = $translations[$this->langOnly]['tx_seo_priority'];
$itemID = $item['uid'];
}
// if no specific language is chosen, display all translations of a page
Expand Down Expand Up @@ -318,9 +320,11 @@ protected function renderSEOTable($tree) {
$tCells[] = '<td>Title&nbsp;Tag</td>';
$tCells[] = '<td>Keywords</td>';
$tCells[] = '<td>Description</td>';
$tCells[] = '<td>Priority</td>';
} else {
$tCells[] = '<td colspan="2">Title&nbsp;Tag</td>';
$tCells[] = '<td colspan="2">Keywords</td>';
$tCells[] = '<td colspan="2">Priority</td>';
}
$output = '<tr class="bgColor5 tableheader t3-row-header">' . implode(LF, $tCells) . '</tr>' . $output;

Expand All @@ -345,6 +349,7 @@ protected function renderRowContent($item, $rowTitle = NULL) {
$row1[] = $item['tx_seo_titletag'];
$row1[] = $item['keywords'];
$row1[] = $item['description'];
$row1[] = ((double)$item['tx_seo_priority'] > 0) ? $item['tx_seo_priority'] : '0.5';

// before output, wrap each cell in tds
foreach ($row1 as $k => $v) {
Expand All @@ -354,8 +359,8 @@ protected function renderRowContent($item, $rowTitle = NULL) {
// display fields that can be edited
$tbl = ($item['sys_language'] > 0 ? 'pages_language_overlay' : 'pages');
$fName = 'tx_seo[' . $tbl . '][' . $item['uid'] . ']';
$row1[] = '<td>Title-Tag:</td><td><input name="' . $fName . '[tx_seo_titletag]" value="' . htmlspecialchars($item['tx_seo_titletag']) . '" type="text" size="43" maxlength="100" autocomplete="off" class="seoTitleTag"/></td><td>Keywords:</td><td><input name="' . $fName . '[keywords]" value="' . htmlspecialchars($item['keywords']) . '" type="text" size="67" maxlength="180" autocomplete="off" class="seoKeywords"/></td>';
$row2[] = '<td>Description:</td><td colspan="3"><input name="' . $fName . '[description]" value="' . htmlspecialchars($item['description']) . '" type="text" size="120" autocomplete="off" class="seoDescription"/><br/><br/></td>';
$row1[] = '<td>Title-Tag:</td><td><input name="' . $fName . '[tx_seo_titletag]" value="' . htmlspecialchars($item['tx_seo_titletag']) . '" type="text" size="43" maxlength="100" autocomplete="off" class="seoTitleTag"/></td><td>Keywords:</td><td><input name="' . $fName . '[keywords]" value="' . htmlspecialchars($item['keywords']) . '" type="text" size="67" maxlength="180" autocomplete="off" class="seoKeywords"/></td><td>Priority:</td><td><input name="' . $fName . '[tx_seo_priority]" value="' . htmlspecialchars($item['tx_seo_priority']) . '" type="text" size="5" maxlength="5" autocomplete="off" class="seoPriority"/></td>';
$row2[] = '<td>Description:</td><td colspan="5"><input name="' . $fName . '[description]" value="' . htmlspecialchars($item['description']) . '" type="text" size="120" autocomplete="off" class="seoDescription"/><br/><br/></td>';
}

if ($this->hasAvailableLanguages) {
Expand Down Expand Up @@ -388,7 +393,7 @@ protected function loadLanguageOverlays($uidList) {
$where = ($this->langOnly ? ' AND sys_language_uid = ' . $this->langOnly : '');

$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
'uid, pid, sys_language_uid, title, tx_seo_titletag, keywords, description',
'uid, pid, sys_language_uid, title, tx_seo_titletag, tx_seo_priority, keywords, description',
'pages_language_overlay',
'pid IN ('.$uidList .') ' . $where . BackendUtility::BEenableFields('pages_language_overlay'),
'',
Expand All @@ -402,6 +407,7 @@ protected function loadLanguageOverlays($uidList) {
'uid' => $row['uid'],
'title' => $row['title'],
'tx_seo_titletag' => $row['tx_seo_titletag'],
'tx_seo_priority' => (double)$row['tx_seo_priority'] > 0 ? $row['tx_seo_priority'] : '0.5',
'keywords' => $row['keywords'],
'description' => $row['description']
);
Expand Down Expand Up @@ -503,15 +509,16 @@ protected function saveChanges() {
// run through every item in the table
foreach ($res as $uid => $item) {
$uid = intval($uid);
if (empty($item['tx_seo_titletag']) && empty($item['keywords']) && empty($item['description'])) {
if (empty($item['tx_seo_titletag']) && empty($item['keywords']) && empty($item['description']) && empty('tx_seo_priority')) {
$emptyItems[] = $uid;
continue;
}

$fields = array(
'tx_seo_titletag' => $item['tx_seo_titletag'],
'keywords' => $item['keywords'],
'description' => $item['description']
'description' => $item['description'],
'tx_seo_priority' => $item['tx_seo_priority']
);
$GLOBALS['TYPO3_DB']->exec_UPDATEquery($tbl,'uid = '.$uid,$fields);
}
Expand All @@ -523,7 +530,8 @@ protected function saveChanges() {
$fields = array(
'tx_seo_titletag' => '',
'keywords' => '',
'description' => ''
'description' => '',
'tx_seo_priority' => '0.5'
);
$GLOBALS['TYPO3_DB']->exec_UPDATEquery($tbl,'uid IN ('.$uidList.')',$fields);
}
Expand Down
9 changes: 7 additions & 2 deletions Classes/Controller/SitemapController.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,12 @@ public function renderXMLSitemap($content, $configuration) {
// format date, see http://www.w3.org/TR/NOTE-datetime for possible formats
$lastmod = date('c', $lastmod);

$priority = ((double)$item['tx_seo_priority'] > 0) ? (double)$item['tx_seo_priority'] : 0.5;
$this->usedUrls[$url] = array(
'url' => $url,
'lastmod' => $lastmod
'lastmod' => $lastmod,
'priority' => $priority
);
}

Expand Down Expand Up @@ -164,7 +167,8 @@ public function renderXMLSitemap($content, $configuration) {

$content .= '
<url>
<loc>' . htmlspecialchars($urlData['url']) . '</loc>' . $lastModificationDate . '
<loc>' . htmlspecialchars($urlData['url']) . '</loc>
<priority>' . $urlData['priority'] . '</priority>' . $lastModificationDate . '
</url>';
}

Expand Down Expand Up @@ -407,7 +411,7 @@ protected function resolveBaseUrl() {
*/
protected function fetchPagesFromTreeStructure($id) {
$depth = 50;
$additionalFields = 'uid,pid,doktype,shortcut,crdate,SYS_LASTCHANGED,shortcut_mode,l18n_cfg';
$additionalFields = 'uid,pid,doktype,shortcut,crdate,SYS_LASTCHANGED,shortcut_mode,l18n_cfg,tx_seo_priority';

// Initializing the tree object
$treeStartingRecord = $this->getFrontendController()->sys_page->getRawRecord('pages', $id, $additionalFields);
Expand Down Expand Up @@ -440,6 +444,7 @@ protected function fetchPagesFromTreeStructure($id) {
$tree->addField('doktype', 1);
$tree->addField('nav_hide', 1);
$tree->addField('l18n_cfg', 1);
$tree->addField('tx_seo_priority', 1);

// disable recycler and everything below
$tree->init('AND doktype!=255' . $this->getFrontendController()->sys_page->enableFields('pages'));
Expand Down
18 changes: 17 additions & 1 deletion Configuration/TCA/Overrides/pages.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,21 @@
)
),
);
),
'tx_seo_priority' => array(
'exclude' => 1,
'label' => 'LLL:EXT:seo_basics/Resources/Private/Language/db.xml:pages.priority',
'config' => array(
'type' => 'input',
'size' => 70,
'eval' => 'trim,double2',
'range' => array(
'lower' => 0,
'upper' => 1
),
'default' => 0.5
)
)
);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns('pages', $additionalColumns);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes('pages', 'tx_seo_titletag, tx_seo_canonicaltag, tx_seo_robots', 1, 'before:keywords');
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes('pages', 'tx_seo_titletag, tx_seo_canonicaltag, tx_seo_robots, tx_seo_priority', 1, 'before:keywords');
17 changes: 17 additions & 0 deletions Configuration/TCA/Overrides/pages_language_overlay.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,26 @@
),
)
),
),
'tx_seo_priority' => array(
'exclude' => 1,
'label' => 'LLL:EXT:seo_basics/Resources/Private/Language/db.xml:pages.priority',
'config' => array(
'type' => 'input',
'size' => 70,
'eval' => 'trim,double2',
'range' => array(
'lower' => 0,
'upper' => 1
),
'default' => 0.5
)
)
);

\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns('pages_language_overlay', $additionalColumns);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes('pages_language_overlay', 'tx_seo_titletag, tx_seo_canonicaltag, tx_seo_robots', '1', 'before:keywords');
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes('pages_language_overlay', 'tx_seo_titletag, tx_seo_canonicaltag, tx_seo_priority', '1', 'before:keywords');

$GLOBALS['TCA']['pages_language_overlay']['interface']['showRecordFieldList'] .= ',tx_seo_titletag, tx_seo_canonicaltag, tx_seo_robots';
$GLOBALS['TCA']['pages_language_overlay']['interface']['showRecordFieldList'] .= ',tx_seo_titletag, tx_seo_canonicaltag, tx_seo_priority';
2 changes: 2 additions & 0 deletions Resources/Private/Language/db.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@
<label index="pages.tx_seo_robots.I.1">noindex</label>
<label index="pages.tx_seo_robots.I.2">noindex,follow</label>
<label index="pages.tx_seo_robots.I.3">index,nofollow</label>
<label index="pages.priority">Sitemap Priority:</label>
<label index="module.title">SEO Management</label>
</languageKey>
<languageKey index="de" type="array">
<label index="pages.titletag">Title Tag:</label>
<label index="pages.canonicaltag">Canonical URL:</label>
<label index="pages.tx_seo_robots">Zusätzliche &quot;robots&quot;-Metatags für diese Seite</label>
<label index="pages.tx_seo_robots.I.0">keine zusätzliche Konfiguration</label>
<label index="pages.priority">Sitemap Priority:</label>
<label index="module.title">SEO Management</label>
</languageKey>
</data>
Expand Down
4 changes: 2 additions & 2 deletions ext_localconf.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
defined('TYPO3_MODE') or die();

// adding th tx_seo_titletag to the pageOverlayFields so it is recognized when fetching the overlay fields
$GLOBALS['TYPO3_CONF_VARS']['FE']['pageOverlayFields'] .= ',tx_seo_titletag,tx_seo_canonicaltag,tx_seo_robots';
// adding all tx_seo_* fields to the pageOverlayFields
$GLOBALS['TYPO3_CONF_VARS']['FE']['pageOverlayFields'] .= ',tx_seo_titletag,tx_seo_canonicaltag,tx_seo_robots,tx_seo_priority';

$extensionConfiguration = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['seo_basics']);

Expand Down
5 changes: 4 additions & 1 deletion ext_tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
CREATE TABLE pages (
tx_seo_titletag tinytext,
tx_seo_canonicaltag tinytext,
tx_seo_robots tinytext
tx_seo_robots tinytext,
tx_seo_priority tinytext
);

#
Expand All @@ -14,4 +15,6 @@ CREATE TABLE pages_language_overlay (
tx_seo_titletag tinytext,
tx_seo_canonicaltag tinytext,
tx_seo_robots tinytext
tx_seo_canonicaltag tinytext,
tx_seo_priority tinytext
);