symfony - Symfony2/Doctrine - How to select a single tag from a blog.tags property -


How do I choose a tag from blog.tags? I'm trying to add a tag to the blog.tags property. Now when I hover over a single tag, I look at the group of tags instead of just a single one.

Tags

Tags for Posts < P> Group of tags while hovering over a tag:

Group tag instead of just one

I am using Loop for all blogs and this is the property in the tweak file. I need to be able to choose to link each tag in the blog tag field, how do I set it?

Toggle file

 % blogging for% {% blog in%} {blog.tagsArray%} for tag% lt; P & gt; Tags: & lt; Span class = "highlight" & gt; & Lt; {{Path ('AcmeDemoBundle_tag', {'tag': tag}}}} {{tag}}    P & gt; & lt; br & gt; {% Endfor%} {% endfor%}   

Entity

  / ** * @ wise string * * @ORM \ column (name = "tag", type = "text") * / private $ tag; / ** * set tag * * @ ultimate string $ Tag * @ layer blog * / public function set tag ($ tag) {$ this-> tag = $ tag; $ this return;} / ** * get tag * * @ returning string * / public function getTags ( } {Refund $ this-> tag;}   

Controller

  Public function index action ($ tag = null) {$ em = $ this-> getDoctrine () -> getManager (); $ blog = $ em- & gt; getRepository ('LSHealthFitnessBundle: blog') - & GetBags (); $ Tag = $ em-> GetRepository ('LSHealthFitnessBundle: Blog') - & gt; GetTags (); $ Post Tags = $ em- & gt; getRepository ('LSHealthFitnessBundle: blog') - & Gt; getPostsByTags ($ tag); $ Paginator = $ this- & gt; Get ('knp_paginator'); $ Pagination = $ pageitator- & gt; Paginated ($ blog, $ this- & gt; receive ('request') - & gt; query- & gt; receive ('page', 1) / * page number * /, 5 / * limit per page * /); Returns array ('blog' = & gt; $ blogs, 'tag' = & gt; $ tag, 'post tags'' & gt; $ post tag, 'endorsement' = & gt; $ marking page;); }   

List formats: (response to response)

Enter image details here

  {% pagination % {@} For tags in% {blog.tagsArray%} for blogs in%} & lt; A href = "{{path ('AcmeDemoBundle_tag', {'tag': tag})}}" & gt; {{Tags}} & lt; / A & gt; & Amp; Nbsp; {% Endfor%} & lt; Br / & gt; {% Endfor%}   

This will create a list of tags for each blog (in each separate line)

[edit]:

  public function getTagsArray () {return explosion (',', $ this-> tag); }   

This tag will convert the string to an array (comma delimited). Then you can get the tag array by calling blog.tagsArray in the toggle I updated the code above

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -