Zum Inhalt springen

Macina Bannermanagement

Erstellt am 26. April 2006 · 9 Antworten · letzte Antwort am 24. November 2008

Tags: Frage

kruemelchen26 ·

Hallo Leute,

nach ewigem probieren, googlen und hier suchen muss ich nun Euch um Rat fragen.

Ich habe auf unseren Fussballseiten das Macina Bannermanagement installiert und eingerichtet. Die Banner werden ordnungsgemäß angezeigt, aber als Url erscheint immer folgendes (id ändert sich natürlich):

http://www.kfv-fussball-wittenberg.de/index.php?id=3&no_cache=1&tx_macinabanners_pi1[banneruid]=4

Die Seiten sind mit Frames aufgebaut und in der für die Banner steht folgendes:

<!--- ###rowbanner### begin -->
<table border="0" cellpadding="0" cellspacing="0">
<tr>
    <!-- ###row### begin -->
    <td align="left" valign="middle">###banner###</td>
    <!-- ###row### end -->
</tr>
</table>
<!--- ###rowbanner### end -->

Im Setup siehts so aus:

rechtsFrame.10 { 
	template = FILE 
	template.file = fileadmin/kfv/rechtsFrame.php
        workOnSubpart = DOCUMENT_BODY
        subparts.rowbanner < plugin.tx_macinabanners_pi1
        subparts.rowbanner {
             parser < tt_content.text.20.parseFunc
             pidList = 69
             recursive = 0
             placement = top
             mode = random
             results_at_a_time = 1
        }
}

Fällt jemanden von Euch etwas ein warum die Links nicht angezeigt werden? Was mach ich nur falsch?

Grüße und vorab Danke für alle Hinweise
Marko

laptop24 ·

Hallo,

es ist doch alles da, was da sein sollte. Die Ziel-URL ist deshalb nicht direkt angegeben, damit die Erweiterung die Klicks zählen kann.

Wenn der Link direkt in den HTML-Code geschrieben wird, dann lädt der Browser beim anklicken direkt die angegebene URL. Mit der Methode die Macina benutzt, benachrichtigt der Browser quasi die Erweiterung, dass der Link angefordert wurde. Die Erweiterung notiert das (zählt also die Klicks) und leitet den Browser anschliessend zur gewünschten Ziel-URL um.

Damit ist also alles im grünen Bereich. Oder funktioniert die Extension etwa nicht?

kruemelchen26 ·

Hallo laptop24

das ist ja eben mein Problem. Es öffnet sich ein neues Fenster wie gewünscht, nur wird dort nicht die bei dem Banner hinterlegte Seite geöffnet sonder die zur Zeit angezeigte Typo3 Seite. Es funktioniert auf 3 verschiedenen Typo3 Seiten nicht und ich weiss einfach nicht mehr was ich verkehrt mache.

Grüße Marko

laptop24 ·

Ok. Die hits sind die Anzahl der Auslieferungen, sprich wie oft die Seite angezeigt wurde. Die Klicks wären die Anzahl, wie oft auf den Link geklickt wurde.

Liegt da evtl. ein Software-Bug vor? Hm...

kruemelchen26 ·

So Thema hat sich erledigt. Nach ein wenig hier und dort editieren der Extension läuft es nun endlich. Clicks und Counts werden auch ordnungsgemäß mitgezählt.

Grüße Marko

Toto Cologne ·

Hallo Kruemelchen,

ich plage mich auch mit dem Problem rum, dass macina_banners nicht clicks sondern wohl hits/views oder sonstwas zaehlt. Unser Programmierer kommt zu dem Schluss, dass daran nichts zu aendern ist.
Aus Deinem letzten Post zu dem Thema lese ich, dass Du das Problem wohl doch loesen konntest. "Clicks und Counts werden auch ordnungsgemäß mitgezählt."

Verraetst Du mir, an welchen Schrauben wir drehen muessen, damit macina_banners die clicks/Klicks vernuenftig zaehlt? Kann man auch die Klicks aus der eigenen Firma rausrechnen?

Besten Dank im Voraus
Toto

kruemelchen26 ·

Aufgrund der Anfragen per PN, ist hier mal meine class.tx_macinabanners_pi1.php. Da ich nicht mehr weiß was geändert wurde vergleicht diese einfach mal.

<?php
	/***************************************************************
	*  Copyright notice
	*
	*  (c) 2003 Wolfgang Becker (wb@macina.com)
	*  All rights reserved
	*
	*  This script is part of the Typo3 project. The Typo3 project is
	*  free software; you can redistribute it and/or modify
	*  it under the terms of the GNU General Public License as published by
	*  the Free Software Foundation; either version 2 of the License, or
	*  (at your option) any later version.
	*
	*  The GNU General Public License can be found at
	*  http://www.gnu.org/copyleft/gpl.html.
	*
	*  This script is distributed in the hope that it will be useful,
	*  but WITHOUT ANY WARRANTY; without even the implied warranty of
	*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	*  GNU General Public License for more details.
	*
	*  This copyright notice MUST APPEAR in all copies of the script!
	***************************************************************/
	/**
	* Plugin 'Bannermodule' for the 'macina_banners' extension.
	*
	* @author Wolfgang Becker <wb@macina.com>
	*/
	require_once(PATH_tslib . 'class.tslib_pibase.php');
	
	/**
	 * Class for creating a banner extension
	 * 
	 * @author	Wolfgang <wb@macina.com>
	 * @package TYPO3
	 * @subpackage tx_macinabanners
	 */ 
	class tx_macinabanners_pi1 extends tslib_pibase {
	
		var $prefixId = 'tx_macinabanners_pi1'; // Same as class name
		var $scriptRelPath = 'pi1/class.tx_macinabanners_pi1.php'; // Path to this script relative to the extension dir.
		var $extKey = 'macina_banners'; // The extension key.
		var $siteRelPath;
		
		/**
		 * main function invoked by index.php
		 * 
		 * @param	string		$content: main variable carriing the content
		 * @param	array		$conf: config array from typoscript
		 * @return	string		html content
		 */
		function main($content, $conf) {
			 
			$this->pi_USER_INT_obj = 1; // Any link to yourself won't expect to be cached (no cHash and no_cache=1)
			// forwareder
			if ($_GET['banneruid']) {
				$this->conf = $conf;
				$this->pi_setPiVarDefaults();
				$this->pi_loadLL();

				// get link details
				$record = $this->pi_getRecord('tx_macinabanners_banners',$_GET['banneruid'],$checkPage=0);

				if ($record != false) {
					// update clicks
					$clicksquery = 'UPDATE tx_macinabanners_banners SET clicks = clicks+1 WHERE uid = ' . $_GET['banneruid'];
					$clicks = mysql(TYPO3_db, $clicksquery);
					if (mysql_error())
						t3lib_div::debug(array (mysql_error(), $clicksquery ));
					 
					// get URL
					unset($_GET['banneruid']);
					header('Location: ' . t3lib_div::getIndpEnv('TYPO3_SITE_URL') . $this->cObj->getTypoLink_URL($record['url']));
					exit;
				}
			}
			switch ((string)$conf['CMD']) {
				case 'singleView':
					list($t) = explode(':', $this->cObj->currentRecord);
					 
					$this->internal['currentTable'] = $t;
					$this->internal['currentRow'] = $this->cObj->data;
					$content = $this->singleView($content, $conf);
					#t3lib_div::debug(array ($content));
					return $content;
				break;
				default:
					if (strstr($this->cObj->currentRecord, 'tt_content')) {
						$conf['pidList'] = $this->cObj->data['pages'];
						$conf['recursive'] = $this->cObj->data['recursive'];
						$conf['placement'] = $this->cObj->data['tx_macinabanners_placement'];
						$conf['mode'] = $this->cObj->data['tx_macinabanners_mode'];
					}
					//PRS+ 12.08.2005
					if ($conf['mode'] == 'random') 
					{
						$substKey = 'INT_SCRIPT.'.$GLOBALS['TSFE']->uniqueHash();
						$link='<!--'.$substKey.'-->';
						$conf['userFunc'] = 'tx_macinabanners_pi1->listView';
						$GLOBALS['TSFE']->config['INTincScript'][$substKey] = array(
							'conf'=>$conf,
							'cObj'=>serialize($this->cObj),
							'type'=>'FUNC',
						);
						error_log(__FILE__.':'.__LINE__.':'.var_export($GLOBALS['TSFE']->config['INTincScript'][$substKey],true),0);
						#t3lib_div::debug(Array("link"=>$link));
						return $link;

					} else {
						return $this->listView($content, $conf);
					}			
					//PRS- 12.08.2005
				break;
			}
		}
		 
		/***************************
		 * 
		 * listfunktions
		 *
		 **************************/

		/**
		 * main function for output of the listview and the singleview
		 * 
		 * @param	string		$content: main variable carriing the content
		 * @param	array		$conf: config array from typoscript
		 * @return	string		html content
		 */
		function listView($content, $conf) {

			$this->conf = $conf; // Setting the TypoScript passed to this function in $this->conf
			 
			$this->pi_setPiVarDefaults();
			$this->pi_loadLL();	// Loading the LOCAL_LANG values
			
			
			$this->siteRelPath = $GLOBALS['TYPO3_LOADED_EXT'][$this->extKey]['siteRelPath'];
			 
			// order by
			$orderby = 'ORDER BY sorting';
			 
			$this->internal['results_at_a_time'] = t3lib_div::intInRange($lConf['results_at_a_time'], 0, 1000, 1000); // Number of results to show in a listing.
			 
			 //passende sprache oder sprachunabhaengig
			$where .=" AND (sys_language_uid = " . $GLOBALS["TSFE"]->sys_language_uid . " OR sys_language_uid = -1) ";
			// nur banner mit dem richtigen placement (left right top bottom) holen
			$where .= "AND placement LIKE '" . $conf['placement'] . "' ";
			// alle banner die die aktuelle page id nicht in  excludepages stehen haben
			$where .= "AND NOT ( excludepages regexp '[[:<:]]".$GLOBALS['TSFE']->id."[[:>:]]' )"; 
			 
			// Make listing query, pass query to MySQL:
			$query = $this->pi_list_query('tx_macinabanners_banners', 0, $where, '', '', $orderby);
			$res = mysql(TYPO3_db, $query);
			if (mysql_error()) t3lib_div::debug(array (mysql_error(), $query ));
				
			// banner aussortieren
			$bannerdata = array();
			while ($row = mysql_fetch_assoc($res)) {
				
				if($row['pages'] && $row['recursiv']){ // wenn pages nicht leer und rekursiv angehakt ist
					
					// liste der pageids rekursiv holen
					$pidlist = $this->pi_getPidList($row['pages'],255);
					
					$pidArray = array_unique(t3lib_div::trimExplode(',',$pidlist,1));
					#t3lib_div::debug(array($pidlist,$pidArray));
					if(in_array($GLOBALS['TSFE']->id,$pidArray)){
						$bannerdata[] = $row;
					}
					
				} else if($row['pages'] && !$row['recursiv']){
					// wenn pages nicht leer und rekursiv nicht angehakt ist
					
					$pidArray = array_unique(t3lib_div::trimExplode(',',$row['pages'],1));
					if(in_array($GLOBALS['TSFE']->id,$pidArray)){
						$bannerdata[] = $row;
					}
					
				} else {
					// wenn pages leer und rekursiv nicht angehakt ist
					
					$bannerdata[] = $row;
				}
			}
			
			$count = count($bannerdata);
			
			// use mode "random
			if ($conf['mode'] == "random" && $count > 1) {
				$randomselectnum = rand(0, $count - 1);
				$randombanner = $bannerdata[$randomselectnum];
				unset($bannerdata);
				$bannerdata[] = $randombanner;
			}
			
			// get template
			$this->templateCode = $this->cObj->fileResource($this->conf['templateFile']);
			 
			// get main subpart
			$templateMarker = '###template_banners###';
			$template = array ();
			$template = $this->cObj->getSubpart($this->templateCode, $templateMarker);
			 
			// get row subpart
			$rowmarker = '###row###';
			$tablerowarray = array ();
			$tablerowarray = $this->cObj->getSubpart($template, $rowmarker);
			 
			$rowdata = '';
			 
			 // limit number of banners shown
			$qt = $conf['results_at_a_time'] < count($bannerdata) ? $conf['results_at_a_time'] : count($bannerdata);

			for ($i=0; $i<$qt; $i++){
				
				$row = $bannerdata[$i];		
				
				// update impressionsfeld on rendering banner
				$impressionsquery = 'UPDATE tx_macinabanners_banners SET impressions = impressions+1 WHERE uid = ' . $row['uid'];
				$impressions = mysql(TYPO3_db, $impressionsquery);
				if (mysql_error()) t3lib_div::debug(array (mysql_error(), $impressionsquery ));
				 
				// assign borders to array
				$styles = array ('margin-top' => $row['border_top'], 
								'margin-right' => $row['border_right'],
								'margin-bottom' => $row['border_bottom'], 
								'margin-left' => $row['border_left'] );
				 
				switch($row['bannertype']) {
					case 0:
					$img = $this->conf['image.'];
					 
					if ($row['maxw'] < $this->conf['image.']['file.']['maxW'] && $row['maxw']>0) {
						$img['file.']['maxW'] = $row['maxw'];
					}

					$img['file'] = 'uploads/tx_macinabanners/' . $row['image'];
					$img['alttext'] = $row['alttext'];

					$img = $this->cObj->IMAGE($img);
					 
					// link image with pagelink und bannerlink as getvar
					if ($row['url']) {
											 
						// use typolinkfunction to get pagelink
						$link = $this->cObj->getTypoLink_URL($row['url']);
						
						$pos = strpos ($link, "http://");
						if ($pos === false) {
							// link to this page with params
							$wrappedSubpartArray['###bannerlink###'] = t3lib_div::trimExplode("|", $this->pi_linkTP("|", array ('banneruid' => $row['uid']),1),1);
							$banner = $this->pi_linkTP($img, array ('banneruid' => $row['uid']),1);
						} else {
							$wrappedSubpartArray['###bannerlink###'] = array('<a href="http://www.kfv-fussball-wittenberg.de/typo3conf/ext/macina_banners/pi1/class.tx_macinabanners_launchpage.php?uid=' . $row['uid'] . '&link=' . urlencode($link) . '" target="_blank">', '</a>');
							# $wrappedSubpartArray['###bannerlink###'] = array('<a href="'.$this->siteRelPath.'pi1/class.tx_macinabanners_launchpage.php?uid=' . $row['uid'] . '" target="_blank">', '</a>');
							// use launchpage to count clicks for external links
							$banner = $wrappedSubpartArray['###bannerlink###'][0] . $img . $wrappedSubpartArray['###bannerlink###'][1];
						}
						
					} else {
						$banner = $img;
					}
					break;
					
					case 1:
					$banner = "\n<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" width=\"" . $row['flash_width'] . "\" height=\"" . $row['flash_height'] . "\">\n";
					$banner .= "<param name=\"movie\" value=\"uploads/tx_macinabanners/" . $row['swf'] . "\" />\n";
					$banner .= "<param name=\"quality\" value=\"high\" />\n";
					$banner .= "<param name=\"allowScriptAccess\" value=\"sameDomain\" />\n";
					$banner .= "<param name=\"menu\" value=\"false\" />\n";
					$banner .= "<param name=\"wmode\" value=\"transparent\" />\n";
					$banner .= "<embed src=\"uploads/tx_macinabanners/" . $row['swf'] . "\" quality=\"high\" wmode=\"transparent\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\"" . $row['flash_width'] . "\" height=\"" . $row['flash_height'] . "\"></embed>\n";
					$banner .= "</object>\n";
					break;
				}
				 
				// funktion to attach styles to wrapping cell
				$banner = $this->wrapwithstyles($banner, $styles);
				 
				// create the content by replacing the marker in the template
				$markerArray = array ();
				$markerArray['###banner###'] = $banner;
				$markerArray['###alttext###'] = $row['alttext'];
				$markerArray['###filename###'] = $row['bannertype'] == 0?$row['image']:$row['swf'];
				$markerArray['###url###'] = $row['url'];
				$markerArray['###impressions###'] = $row['impressions'];
				$markerArray['###clicks###'] = $row['clicks'];
				$markerArray['###edit###'] = $this->pi_getEditPanel($row, 'tx_macinabanners_banners');
				 
				$rowdata .= $this->cObj->substituteMarkerArrayCached($tablerowarray, $markerArray, array (), $wrappedSubpartArray);
			}
			if($rowdata)
			{
				$subpartArray = array ();
				$subpartArray['###row###'] = $rowdata;
				$content = $this->cObj->substituteMarkerArrayCached($template, array (), $subpartArray, array ());
				return $content;
			} else
			{
				return;  // keine banner
			}
		}
		
		/**
		 * output of a single view element called by pi_list_makelist
		 * 
		 * @param	string		$content: main variable carriing the content
		 * @param	array		$conf: config array from typoscript
		 * @return	string		html content
		 */
		function singleView($content, $conf) {
			$this->conf = $conf;
			 
			$this->pi_setPiVarDefaults();
			$this->pi_loadLL();

			switch($this->internal['currentRow']['bannertype']) {
			case 0:
				 
				$img = $this->conf['image.'];
				
				if ($this->internal['currentRow']['maxw'] < $this->conf['image.']['file.']['maxW']) {
					$img['file.']['maxW'] = $this->internal['currentRow']['maxw'];
				}
				
				
				$img['file'] = 'uploads/tx_macinabanners/' . $this->internal['currentRow']['image'];
				$img['alttext'] = $this->internal['currentRow']['alttext'];
				 
				$img = $this->cObj->IMAGE($img);
				 
				$content = "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tr>\n<td nowrap valign=\"top\"><a href = \"".$this->cObj->getTypoLink_URL($this->internal['currentRow']['url'])."\">". $img . "</a></td>\n</tr>\n</table>\n";
				break;
				
			case 1: 
				$banner = "\n<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" width=\"" . $this->internal['currentRow']['flash_width'] . "\" height=\"" . $this->internal['currentRow']['flash_height'] . "\">\n";
				$banner .= "<param name=\"movie\" value=\"uploads/tx_macinabanners/" . $this->internal['currentRow']['swf'] . "\" />\n";
				$banner .= "<param name=\"quality\" value=\"high\" />\n";
				$banner .= "<param name=\"allowScriptAccess\" value=\"sameDomain\" />\n";
				$banner .= "<param name=\"menu\" value=\"false\" />\n";
				$banner .= "<embed src=\"uploads/tx_macinabanners/" . $this->internal['currentRow']['swf'] . "\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\"" . $this->internal['currentRow']['flash_width'] . "\" height=\"" . $this->internal['currentRow']['flash_height'] . "\"></embed>\n";
				$banner .= "</object>\n";
				
				$content = $banner;
				break;
			}
			
			return $content;
		}

		/**
		 * wrapwithstyles wraps the banner with a table that creates the borders left right top and bottom
		 * 
		 * @param	string		$string: contains the html bannercode
		 * @param	array		$styles: named array with the styles padding-top, padding bottom ...
		 * @return	string		html content
		 */
		function wrapwithstyles($string, $styles) {
			$content = "<div style=\"";
			foreach ($styles as $key => $value) {
				$content .= $key . ':' . $value . 'px; ';
			}
			$content .= "\">" . $string . "</div>\n";
			return $content;
		}
	}
	 
	if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/macina_banners/pi1/class.tx_macinabanners_pi1.php']) {
		include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/macina_banners/pi1/class.tx_macinabanners_pi1.php']);
	}
?>