Zum Inhalt springen

content rendern ohne body tag

Erstellt am 5. März 2008 · 2 Antworten · letzte Antwort am 8. März 2008

Tags: JavaScript & AJAX, Frage

masterjcl ·

Gibt es eine Möglichkeit Content ohne den Body und Head auszugeben ??

Ich benötige das für ein paar ajax funktionen sonst muss ich jedesmal manuell den Content aus dem Response extrahieren.

Ideal währe es wenn es typoscript im Seitenbaum abbeschaltet werden kann.

mfg

masterjcl ·

Für alle die auch ein derartiges Problem haben ich habe ein Skeleton geschrieben damit sollten sich alle Probleme lösen lassen. Feedback erwünscht. Mir wird hier auch immer so schnell geholfen ;-)

<?php
/*
 Ajax XML Skeleton Service for Typo3 v4.2 
 by Hit-Enter X-Solution
 Jens-Carsten Lukas
 jc.lukas@hit-enter.de
 Important:
 insert into ext_localconf.php follow line change ext path to script
 $TYPO3_CONF_VARS['FE']['eID_include']['hex'] = 'EXT:hextouristic/hexservice.php';
 Action URL for getData
 index.php?eID=hex&hexi=0 
*/
// send encoding and send no-cache
header('Content-Type: text/xml; charset=UTF-8');
header("Pragma: no-cache");
header("Expires: 0");
//  some security check and includes
if (!defined ('TYPO3_MODE')) 	die ('Access denied.');
require_once(PATH_tslib . 'class.tslib_pibase.php');
//require_once(PATH_tslib . 'class.tslib_content.php');
//require_once(PATH_t3lib . 'class.t3lib_stdgraphic.php');
//require_once(PATH_tslib . 'class.tslib_gifbuilder.php');
require_once(PATH_tslib . 'class.tslib_eidtools.php');
//require_once(PATH_t3lib . 'class.t3lib_page.php');

class hexservice extends tslib_pibase {
var $feUserObj = null;
var $pageid=0;
var $action=0;
var $output='';
// Query-Data  related
var $table='fe_users left join tt_address on fe_users.fkgoogle=tt_address.uid ';
var $get_fields='*';
var $where='fe_users.fkgoogle > 0';
var $fields =  array(
                     'uid',
                     'tx_rggooglemap_lng',
                     'tx_rggooglemap_lat',
                     'tx_rggooglemap_tab',
                     'street',
                     'zip',
                     'city',
                     'first_name',
                     'last_name',
                     'name',
                     'telephone',                                                                                    
                     'www',
                     'email',
                     'image'                                          
                    );
// end of Data related Section
function main(){
               // some pre init's
               $this->feUserObj = tslib_eidtools::initFeUser();
               tslib_eidtools::connectDB();
               // get the Action Codes and some Stuff
               $this->action=intval(t3lib_div::_GET('hexi'));
               $this->pageid=intval(t3lib_div::_GET('pageId'));
               $piVars['pageId'] = intval(t3lib_div::_GET('pageId'));               
               // some Actions
               switch($this->action){
               case 0: 
                     $this->getData();
                     print $this->output;
                     break;
               case 1: 
                     $this->test();
                     print $this->output;
                     break;
               default:
                     print '<warn>Warning: there is no Action for hexservice Service !</warn>';
               }
}

protected function test(){
$this->output='<test>Test Function !</test>';
}

protected function tagMake($data,$ref){
foreach($ref as $fieldname):
  $this->output .= '<'.$fieldname.'>' . $data[$fieldname]  . '</'.$fieldname.'>';
endforeach;
}

protected function getData(){
           		$query = $GLOBALS['TYPO3_DB']->SELECTquery($this->get_fields, $this->table, $this->where, null, null, null);
 		          $result = $GLOBALS['TYPO3_DB']->sql_query($query);
		          if($result) {
		                      $this->output .= '<?xml version="1.0" encoding="utf-8" standalone="yes" ?><data>';
  			                  while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) 
                                  {
                                  $this->output .= '<item>';
                                  $this->tagMake($row,$this->fields);
                                  $this->output .= '</item>';
                                  }
                          $this->output .= '</data>';
                          }
}

}
// create Instance and Start the Service
$output = t3lib_div::makeInstance('hexservice');
$output->main();

if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/hextouristic/hexservice.php'])	{
	include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/hextouristic/hexservice.php']);
}

?>