Konfiguration Positionierung Rating auf Seiten (oberhalb/unterhalb) eingebaut
This commit is contained in:
parent
3ce491f16c
commit
0f080a32be
@ -40,10 +40,8 @@ class RateItPage extends \Frontend {
|
|||||||
$this->loadDataContainer('settings');
|
$this->loadDataContainer('settings');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function outputFrontendTemplate($strContent, $strTemplate) {
|
public function generatePage($objPage, $objLayout, $objPageType) {
|
||||||
global $objPage;
|
if ($objPage->addRating) {
|
||||||
|
|
||||||
if ($objPage->addRating && !($strTemplate == $GLOBALS['TL_CONFIG']['rating_template'])) {
|
|
||||||
$actRecord = $this->Database->prepare("SELECT * FROM tl_rateit_items WHERE rkey=? and typ='page'")
|
$actRecord = $this->Database->prepare("SELECT * FROM tl_rateit_items WHERE rkey=? and typ='page'")
|
||||||
->execute($objPage->id)
|
->execute($objPage->id)
|
||||||
->fetchAssoc();
|
->fetchAssoc();
|
||||||
@ -57,16 +55,16 @@ class RateItPage extends \Frontend {
|
|||||||
$rating .= $this->includeJs();
|
$rating .= $this->includeJs();
|
||||||
$rating .= $this->includeCss();
|
$rating .= $this->includeCss();
|
||||||
|
|
||||||
$posMainDiv = strpos($strContent, '<div id="main">');
|
$objTemplate = $objPageType->Template;
|
||||||
$posInsideDiv = strpos($strContent, '<div class="inside">', $posMainDiv);
|
if ($objTemplate) {
|
||||||
|
if ($objPage->rateit_position == 'after') {
|
||||||
$return = substr($strContent, 0, $posInsideDiv).'<div class="inside">';
|
$objTemplate->main .= $rating;
|
||||||
$return .= $rating;
|
} else {
|
||||||
$return .= substr($strContent, $posInsideDiv + strlen('<div id="inside">') + 3);
|
$objTemplate->main = $rating.$objTemplate->main;
|
||||||
$strContent = $return;
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $strContent;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function includeCss() {
|
private function includeCss() {
|
||||||
|
@ -33,7 +33,7 @@ use cgoIT\rateit\RateItBackend;
|
|||||||
/**
|
/**
|
||||||
* Hooks
|
* Hooks
|
||||||
*/
|
*/
|
||||||
$GLOBALS['TL_HOOKS']['outputFrontendTemplate'][] = array('rateit\\RateItPage', 'outputFrontendTemplate');
|
$GLOBALS['TL_HOOKS']['generatePage'][] = array('rateit\\RateItPage', 'generatePage');
|
||||||
$GLOBALS['TL_HOOKS']['simpleAjax'][] = array('rateit\\RateIt', 'doVote');
|
$GLOBALS['TL_HOOKS']['simpleAjax'][] = array('rateit\\RateIt', 'doVote');
|
||||||
$GLOBALS['TL_HOOKS']['parseArticles'][] = array('rateit\\RateItNews', 'parseArticle');
|
$GLOBALS['TL_HOOKS']['parseArticles'][] = array('rateit\\RateItNews', 'parseArticle');
|
||||||
$GLOBALS['TL_HOOKS']['getContentElement'][] = array('rateit\\RateItFaq', 'getContentElementRateIt');
|
$GLOBALS['TL_HOOKS']['getContentElement'][] = array('rateit\\RateItFaq', 'getContentElementRateIt');
|
||||||
|
@ -39,6 +39,7 @@ $GLOBALS['TL_DCA']['tl_page']['config']['ondelete_callback'][] = array('tl_page_
|
|||||||
/**
|
/**
|
||||||
* Palettes
|
* Palettes
|
||||||
*/
|
*/
|
||||||
|
$GLOBALS['TL_DCA']['tl_page']['palettes']['__selector__'][] = 'addRating';
|
||||||
foreach ($GLOBALS['TL_DCA']['tl_page']['palettes'] as $keyPalette => $valuePalette)
|
foreach ($GLOBALS['TL_DCA']['tl_page']['palettes'] as $keyPalette => $valuePalette)
|
||||||
{
|
{
|
||||||
// Skip if we have a array or the palettes for subselections
|
// Skip if we have a array or the palettes for subselections
|
||||||
@ -53,13 +54,31 @@ foreach ($GLOBALS['TL_DCA']['tl_page']['palettes'] as $keyPalette => $valuePalet
|
|||||||
$GLOBALS['TL_DCA']['tl_page']['palettes'][$keyPalette] = $valuePalette;
|
$GLOBALS['TL_DCA']['tl_page']['palettes'][$keyPalette] = $valuePalette;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add subpalettes to tl_page
|
||||||
|
*/
|
||||||
|
$GLOBALS['TL_DCA']['tl_page']['subpalettes']['addRating'] = 'rateit_position';
|
||||||
|
|
||||||
// Fields
|
// Fields
|
||||||
$GLOBALS['TL_DCA']['tl_page']['fields']['addRating'] = array
|
$GLOBALS['TL_DCA']['tl_page']['fields']['addRating'] = array
|
||||||
(
|
(
|
||||||
'label' => &$GLOBALS['TL_LANG']['tl_page']['addRating'],
|
'label' => &$GLOBALS['TL_LANG']['tl_page']['addRating'],
|
||||||
'exclude' => true,
|
'exclude' => true,
|
||||||
'inputType' => 'checkbox',
|
'inputType' => 'checkbox',
|
||||||
'sql' => "char(1) NOT NULL default ''",
|
'sql' => "char(1) NOT NULL default ''",
|
||||||
|
'eval' => array('tl_class'=>'w50 m12', 'submitOnChange'=>true)
|
||||||
|
);
|
||||||
|
|
||||||
|
$GLOBALS['TL_DCA']['tl_page']['fields']['rateit_position'] = array
|
||||||
|
(
|
||||||
|
'label' => &$GLOBALS['TL_LANG']['tl_page']['rateit_position'],
|
||||||
|
'default' => 'before',
|
||||||
|
'exclude' => true,
|
||||||
|
'inputType' => 'select',
|
||||||
|
'options' => array('after', 'before'),
|
||||||
|
'reference' => &$GLOBALS['TL_LANG']['tl_page'],
|
||||||
|
'sql' => "varchar(6) NOT NULL default ''",
|
||||||
|
'eval' => array('mandatory'=>true, 'tl_class'=>'w50')
|
||||||
);
|
);
|
||||||
|
|
||||||
class tl_page_rateit extends rateit\DcaHelper {
|
class tl_page_rateit extends rateit\DcaHelper {
|
||||||
|
@ -31,6 +31,10 @@
|
|||||||
|
|
||||||
$GLOBALS['TL_LANG']['tl_page']['rateit_legend'] = 'Rate It-Einstellungen';
|
$GLOBALS['TL_LANG']['tl_page']['rateit_legend'] = 'Rate It-Einstellungen';
|
||||||
|
|
||||||
$GLOBALS['TL_LANG']['tl_page']['addRating'] = array('Rating aktivieren', 'Aktiviert das Rating für diese Seite');
|
$GLOBALS['TL_LANG']['tl_page']['addRating'] = array('Rating aktivieren', 'Aktiviert das Rating für diese Seite');
|
||||||
|
$GLOBALS['TL_LANG']['tl_page']['rateit_position'] = array('Position', 'Position des Rating (ober- oder unterhalb) der Seite.');
|
||||||
|
|
||||||
|
$GLOBALS['TL_LANG']['tl_page']['before'] = array('oberhalb', 'Anzeige des Texts oberhalb der Seite');
|
||||||
|
$GLOBALS['TL_LANG']['tl_page']['after'] = array('unterhalb', 'Anzeige des Texts unterhalb der Seite');
|
||||||
|
|
||||||
?>
|
?>
|
@ -31,6 +31,10 @@
|
|||||||
|
|
||||||
$GLOBALS['TL_LANG']['tl_page']['rateit_legend'] = 'Rate It-Settings';
|
$GLOBALS['TL_LANG']['tl_page']['rateit_legend'] = 'Rate It-Settings';
|
||||||
|
|
||||||
$GLOBALS['TL_LANG']['tl_page']['addRating'] = array('activate rating', 'Enables the rating for this page');
|
$GLOBALS['TL_LANG']['tl_page']['addRating'] = array('activate rating', 'Enables the rating for this page');
|
||||||
|
$GLOBALS['TL_LANG']['tl_page']['rateit_position'] = array('position', 'position of the rating (before or above) the page.');
|
||||||
|
|
||||||
|
$GLOBALS['TL_LANG']['tl_page']['before'] = array('above', 'Display the text above the page');
|
||||||
|
$GLOBALS['TL_LANG']['tl_page']['after'] = array('below', 'Display the text below the page');
|
||||||
|
|
||||||
?>
|
?>
|
Loading…
Reference in New Issue
Block a user