2016-11-03 9 views
1

symfony gedmo doctrine 확장에서 상위 - 하위 목록보기에 문제가 있습니다. 내 목록에 모든 항목이 같은 수준으로 표시되어 있으며이를 수정하는 방법을 모르겠습니다. datagridvalues을 사용하여 lft 필드로 정렬하려고했지만 작동하지 않습니다.Symfony Doctrine Extensions에 상위 하위 목록이 표시되지 않음

category.orm.yml 파일

Application\AdminBundle\Entity\Category: 
    type: entity 
    table: Category 
    gedmo: 
    tree: 
     type: nested 
    id: 
    id: 
     type: integer 
     generator: 
     strategy: AUTO 
    fields: 
    name: 
     type: string 
     length: 255 
    image_url: 
     type: string 
     length: 255 
    slug: 
     type: string 
     nullable: false 
     unique: true 

    lft: 
     type: integer 
     gedmo: 
     - treeLeft 
    rgt: 
     type: integer 
     gedmo: 
     - treeRight 
    root: 
     type: integer 
     gedmo: 
     - treeRoot 
    lvl: 
     type: integer 
     gedmo: 
     - treeLevel 

    oneToMany: 
    children: 
     targetEntity: Category 
     mappedBy: parent 
    manyToOne: 
    parent: 
     targetEntity: Category 
     inversedBy: children 
     gedmo: 
     - treeParent 
     joinColumns: 
     Category_id: 
      referencedColumnName: id 
    lifecycleCallbacks: { } 

그리고 내 configureListFields 방법 :

protected function configureListFields(ListMapper $listMapper) 
{ 

    $listMapper 
    ->add('id') 
    ->add('name') 
    ->add('slug') 
    ; 
} 

내 목록보기 이미지에서 List view

답변

0

나는이 너무 오래 싸우는 것처럼 보이는)

일부 codeproject의 기사에서 소나타 관리자는 나무 구조 렌더링을 지원하지 않습니다 (2012 년부터 기사가 변경되었을 수 있습니다). 어쨌든 내 솔루션은

내가
public function __toString() 
{ 
    $prefix = ''; 
    for ($i=1; $i<= $this->lvl; $i++){ 
     $prefix .= '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'; 
    } 
    return $prefix . $this->name; 
} 

public function getLaveledTitle() 
{ 
    return (string)$this; 
} 

등을 추가 한 내 category.php에서

configureListFields 방법 CategoryController.php에 내가 변경 한 name 필드

$listMapper 
    //if you will not add 'html' as field type `&nbsp` will not be parsed as html 
    ->add('laveled_title', 'html', array(
      'strip' => true, 
      'label' => 'Category Name' 
    )) 
    ; 

에 preety 간단합니다