[TYPO3-dev] Re: Pagetype shortcut: include an anchor

Philipp philippwrann at gmx.at
Mon Oct 14 15:46:12 CEST 2013


Got it, was pretty complex.

i Added a field in pages TCA (called active_tab). There i configure the tab, that should be opened.

Then i added a hook:
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/tslib/class.tslib_menu.php']['filterMenuPages']['tx_myhook'] = 'Vendor\\Extension\\Hook\\MenuFilterPagesHook';

That hook looks like:
<?php

namespace Vendor\Extension\Hook;

/**
 * Description of MenuFilterPagesHook
 *
 * @author Philipp Wrann
 */
class MenuFilterPagesHook implements \TYPO3\CMS\Frontend\ContentObject\Menu\AbstractMenuFilterPagesHookInterface {
	
	/**
	 * @var \TYPO3\CMS\Frontend\Page\CacheHashCalculator
	 */
	protected $calculator;
	
	/**
	 * @param array $data Array of menu items
	 * @param array $banUidArray Array of page uids which are to be excluded
	 * @param boolean $spacer If set, then the page is a spacer.
	 * @param \TYPO3\CMS\Frontend\ContentObject\Menu\AbstractMenuContentObject $obj The menu object
	 * @return boolean Returns TRUE if the page can be safely included.
	 */
	public function processFilter(array &$data, array $banUidArray, $spacer, \TYPO3\CMS\Frontend\ContentObject\Menu\AbstractMenuContentObject $obj) {
		if ($data['active_tab']  > 0 && $data['doktype'] == \TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_SHORTCUT) {
			if ($this->calculator==NULL) $this->calculator = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Page\\CacheHashCalculator');
			$data['_ADD_GETVARS'] .= '&activeTab='.$data['active_tab'];
			$cHash = $this->calculator->generateForParameters('&id='.$data['uid'].$data['_ADD_GETVARS']);
			$data['_ADD_GETVARS'] .=  '&cHash='.$cHash;
		}
		return TRUE;
	}
}

?>

Then some rewriting to make the generated url nicer.



More information about the TYPO3-dev mailing list