[TYPO3-english] builduing a correct tt_news single link

Lina Wolf liste at linawolf.de
Sun Aug 1 23:25:20 CEST 2010


If you decide to always have the data in the parameter of the url to the 
tt_news single view then you wouldnt want to have urls that look different 
build by another extension. that would give you duploicate content.

Well I solved it by copying getSingleViewLink and creating all variables 
that are needed. But I think thats not really a satisfying way to do it as 
its very complicated:


 /**
 * borrowed from tt_news
 */
 function getSingleViewLink($uid, $urlOnly = false) {
  $conf = $GLOBALS['TSFE']->tmpl->setup['plugin.']['tt_news.'];
  $where = 'uid="'.intval($uid).'" '.$this->cObj->enableFields('tt_news').' 
';
  $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
   'uid,datetime',
   'tt_news',
   $where
  );
  if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
   $token = '|';
   $singlePid = $conf['singlePid'];
   $allowCaching = 1;
   $piVars = array();
   $piVars['year'] = date('Y', $row['datetime']);
   $piVars['month'] = date('m', $row['datetime']);


   $piVarsArray = array('backPid' => ($conf['dontUseBackPid'] ? null : 
$config['backPid']),
     'year' => ($conf['dontUseBackPid'] ? null : ($piVars['year'] ? 
$piVars['year'] : null)),
     'month' => ($conf['dontUseBackPid'] ? null : ($piVars['month'] ? 
$piVars['month'] : null)));

   if (! $conf['useHRDatesSingleWithoutDay']) {
    $piVars['day'] = date('d', $row['datetime']);
   }

   if ($conf['useHRDates']) {
    $piVarsArray['pS'] = null;
    $piVarsArray['pL'] = null;
    $piVarsArray['arc'] = null;
    if ($conf['useHRDatesSingle']) {
     $tmpY = $piVars['year'];
     $tmpM = $piVars['month'];
     $tmpD = $piVars['day'];

     $piVarsArray['year'] = $piVars['year'];
     $piVarsArray['month'] = $piVars['month'];
     $piVarsArray['day'] = ($piVars['day'] ? $piVars['day'] : null);
    }
   } else {
    $piVarsArray['year'] = null;
    $piVarsArray['month'] = null;
   }

   $piVarsArray['tt_news'] = $row['uid'];

   $linkWrap = $this->pi_linkTP_keepPIvars($token, $piVarsArray, 
$allowCaching, $conf['dontUseBackPid'], $singlePid);
   $url = $this->cObj->lastTypoLinkUrl;

   // hook for processing of links
   if 
(is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['tt_news']['getSingleViewLinkHook'])) 
{
    foreach 
($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['tt_news']['getSingleViewLinkHook'] 
as $_classRef) {
     $_procObj = & t3lib_div::getUserObj($_classRef);
     $params = array('singlePid' => &$singlePid, 'row' => &$row, 
'piVarsArray' => $piVarsArray);
     $_procObj->processSingleViewLink($linkWrap, $url, $params, $this);
    }
   }

   if ($conf['useHRDates'] && $conf['useHRDatesSingle']) {
    $piVars['year'] = $tmpY;
    $piVars['month'] = $tmpM;
    $piVars['day'] = $tmpD;
   }

   if ($urlOnly) {
    return $url;
   } else {
    return $linkWrap;
   }
  }
  return '';
 } 




More information about the TYPO3-english mailing list