[TYPO3-ttnews] active state like menu using LIST and SINGLE on same Page

Sebastian Reinhardt s.reinhardt at 76media.com
Sun Oct 10 12:30:27 CEST 2010


yeah sorry,

i used a hook, i found somewhere else:

make ur own extension with the kickstarter and:
create ur class.myclass.php

edit the ext_localconf.php :
************
if (!defined ('TYPO3_MODE')) die ('Access denied.');
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['tt_news']['extraItemMarkerHook'][] 
= 'EXT:path/class.myclass.php:tx_myclass_current';
************
  e.g: i created an extension called "sxmcurnews" (important, no "_" 
inside the name of ur extensin!!) and created class.sxmcurnews.php

the "last part" of my ext_localconf.php is like
EXT:sxmcurnews/class.sxmcurnews.php:tx_sxmcurnews_marker

the "tx_sxmcurnews_marker" is my class i will use inside my 
class.sxmcurnews.php-file

now edit ur created "class.myclass.php"
*******
<?php
class tx_myclass_current {

function extraItemMarkerProcessor(&$markerArray, &$row, &$lConf, &$pObj) {

		$CURwrap = '<li class="news-item-box news-current">';
		$NOwrap = '<li class="news-item-box">';
		$ENDwrap = '</li>';

		//
			// ID der Aktuellen News in der Seiten URL
			$SINGLEnewsID_array = isset($_GET['tx_ttnews']);
// Wenn keine Variable in der Seiten URL steht wird die Variable mit -1 
gefüllt
			if (!$SINGLEnewsID_array) {
				$SINGLEnewsID = -1;
			} else {
				foreach($_GET['tx_ttnews'] as $key => $value) {
					if ($key == 'tt_news') {
        			 		$SINGLEnewsID = $value;
					}
			}
			}
			// ID der Aktuellen News in der Liste
			$newsID = $row['uid'];
			// Ausgabe der Variablen - Wenn die URL Varuiable gleich  wie die 
Listen ID ist
			if ($newsID == $SINGLEnewsID) {
				$markerArray['###CURNEWSWRAP###'] = $CURwrap;
			} else if ($GLOBALS['TSFE']->register['newscounter'] == 0 && 
$SINGLEnewsID == -1)
//Auf der Einstiegsseite wird der erste aktuelle Beitrag mit der CURRENT 
- Tag ausgezeichnet
  {
				$markerArray['###CURNEWSWRAP###'] = $CURwrap;
			} else {
				$markerArray['###CURNEWSWRAP###'] = $NOwrap;

			}
// Steuervariable, so dass nur der erste Eintrag ausgezeichnet wird
			$GLOBALS['TSFE']->register['newscounter']++;

		// DIV wird wieder geschlossen	
		$markerArray['###CURNEWSWRAPEND###'] = $ENDwrap;
		return $markerArray;

		
}
}



?>
*******
the wrapper can be styled teh way u would like:

$CURwrap = '<div class="news-item-box news-current">';
$NOwrap = '<div class="news-item-box">';
$ENDwrap = '</div>';

Now get ur template of ur news and place the two new markers inside it, 
where u want:
###CURNEWSWRAP###  (this starts the wrapper)
###CURNEWSWRAPEND### (closing the wrapper)

EXAMPLE to create a div box around each list-item where the current gets 
the class news-current:
+++++++news-item-part of the tt:news template : LIST  +++++++++
<!-- ###NEWS### begin
Template for a single item
->###CURNEWSWRAP###
<div class="news-list-item">
   <span class="news-list-date">###NEWS_DATE###</span>
   <h2><!--###LINK_ITEM###-->###NEWS_TITLE###<!--###LINK_ITEM###--></h2>
   <!--###LINK_ITEM###-->###NEWS_IMAGE###<!--###LINK_ITEM###-->
   ###NEWS_SUBHEADER###
   ###CATWRAP_B### ###TEXT_CAT### ###NEWS_CATEGORY###
   ###NEWS_CATEGORY_IMAGE### ###CATWRAP_E###
   <hr class="clearer" /></div>
   ###CURNEWSWRAPEND###
<!-- ###NEWS### end-->
++++++++++++++++

thats the idea of it.



Am 09.10.2010 21:41, schrieb Jordan van Bergen:
> Hoi much later ;-)
>
> On Wed, 06 Oct 2010 13:06:50 +0200, Sebastian Reinhardt
> <s.reinhardt at 76media.com>  wrote:
>
>> solved!!
>>
>> ill explain it  later
>>
>>
>>
>> Am 06.10.2010 00:15, schrieb Sebastian Reinhardt:
>>> Hey,
>>>
>>> (tt_news 3.0.1)
>>>
>>> ive got 2 plugins LIST and the SINGLE on the same page. works great
>>> (using the default news_id..)
>>>
>>> my problem is, that i have to style the current(the active) news_id in
>>> the list, so the user can see, which news hes looking at.
>>>
>>> How can i do that? probably i have to give the the link a class like the
>>> news_id and then check the url which news_id is current.
>>>
>>> sure i can do ths with javascript, but it would be great, if theres a
>>> active state for the items in the list view.
>>>
>>> could anybody help please?
>>>
>>> thx.
>>>



More information about the TYPO3-project-tt-news mailing list