简体   繁体   English

使用Symfony2在TWIG中制作词云

[英]Making Word Clouds in TWIG with Symfony2

I want to create a Word Cloud (Tag Cloud) in a Symfony2 project on my homepage. 我想在主页上的Symfony2项目中创建词云 (标签云)。 I figured it should be done in the TWIG that is rendered for my homepage by passing through to it the array containing my tags and their frequency. 我认为应该通过将包含我的标签及其频率的数组传递给它来完成为我的首页呈现的TWIG。

But that's all I know/guess! 但这就是我所知道的/猜测的! What should be done next, how to create the css for each tag and how(javascript/html/...) this should be done, I have no idea! 接下来应该做什么,如何为每个标签创建CSS,以及如何做到这一点(javascript / html / ...),我不知道!

Can anyone help me please? 谁能帮我吗?

PS: I am a newbie and haven't got my head around how javascripts work with twigs! PS:我是新手,还没弄懂javascript如何与树枝一起工作!

You do not need javascript to show tag cloud in twig. 您不需要javascript即可在树枝中显示标签云。 You just have to make as much css classes as many tag styles you want to have and then you have to connect the frequency of the tag with its class. 您只需要制作尽可能多的css类,就可以拥有想要的多种标签样式,然后必须将标签的频率与其类联系起来。

So it would have to be something like this: 所以它必须是这样的:

Foreach tag in tags, case/if/elseif/elseif... the frequency and print out proper css style for that very frequency. 标签中的foreach标签,case / if / elseif / elseif ...频率,并为该频率打印出适当的CSS样式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM