[TYPO3-news] [TYPO3-project-news] tagcloud for tx_news ?

bernd wilke t3ng at bernd-wilke.net
Wed Sep 16 14:23:51 CEST 2015


Am 28.01.15 um 13:57 schrieb Georg Ringer:
> Hi,
>> this standard list shows ALL tags, but how i get a "weighted" List ???
>
> this is not that easy or more depends on your site. Anyhow you need to
> do that yourself by e.g. checking how often a tag is used.
>
> Best would be to use a custom extension for that

what about a little Typoscript?

page.10.variables.tagcloud = CONTENT
page.10.variables.tagcloud {
   table = tx_news_domain_model_tag
   select {
     selectFields = uid,title,count(*) as cnt
     // use your page-id, where your tags are stored:
     pidInList = 123

     rightjoin = tx_news_domain_model_news_tag_mm ON 
(tx_news_domain_model_tag.uid = 
tx_news_domain_model_news_tag_mm.uid_foreign)
     where = deleted=0 AND hidden=0
     groupBy = uid
     markers {

     }
   }

   renderObj = COA
   renderObj {
     // opening span-tag (you may insert class and style in A-tag)
     10 = COA
     10 {
       // setting explizit font-size via inline style
       10 = COA
       10 {
         10 = TEXT
         10 {
           value = 7+({field:cnt}/2)
           insertData = 1
         }
         stdWrap.prioriCalc = 1
         stdWrap.wrap = style="font-size:|px"
       }
       // setting a class for each count
       20 = TEXT
       20 {
         field = cnt
         noTrimWrap = | class="tag-cnt-|"|
       }
       stdWrap {
         noTrimWrap = |<span |>|
       }
     }

     // tag title & count, linked to filtered overview
     20 = COA
     20 {
       10 = TEXT
       10 {
         field = title
	// append the number of records tagged with this tag:
         dataWrap = |({field:cnt})
       }

       stdWrap {
         typolink {
	  // insert pid where the records list filtered by tag should be displayed:
           parameter = 456
           additionalParams.cObject = TEXT
           additionalParams {
             cObject {
               field = uid
               wrap = &tx_news_pi1[overwriteDemand][tags]=|
             }
           }
         }
       }
     }

     // closing span tag (see .10)
     30 = TEXT
     30.value = </span>

     }
   }
}

in an extension it might be easier to normalize[1] the classes to get an 
unique look independent of current maximum number of records per tag.

[1] spread the current counts to n css-classes defining different 
font-sizes or colors


bernd
-- 
http://www.pi-phi.de/cheatsheet.html


More information about the TYPO3-project-news mailing list