2017-07-17 10 views
0

SeoBundleをインストールし、サイトマップを構築するようにバンドルを設定しました(docs)。symfony - SeoBundleがEMPTYサイトマップを構築

AppKernel.php

new Sonata\SeoBundle\SonataSeoBundle(), 
new Symfony\Cmf\Bundle\CoreBundle\CmfCoreBundle(), 
new Symfony\Cmf\Bundle\SeoBundle\CmfSeoBundle(), 

のフルバンドル構成(config.yml):

sonata_seo: 
    page: 
     title: Erasmus internship – Training Experience 
     metas: 
      name: 
       keywords: Erasmus Internships, Internship in Europe, International Internships, Erasmus+, Erasmus Entrepreneur, Student Internships, Internships Abroad, Student Placements 
       description: Find Internships with Training Experience: Students can find internships & employment opportunities in Europe’s platform for internships. Search paid internships and placements abroad. 
       viewport: width=device-width, initial-scale=1 
       format-detection: telephone=no 
       robots: index, follow 
      property: 
       'og:site_name': Training Experience 
       'og:title': Erasmus internship – Training Experience 
       'og:description': Find Internships with Training Experience: Students can find internships & employment opportunities in Europe’s platform for internships. Search paid internships and placements abroad." 
       'og:url': https://www.trainingexperience.org 
       'og:image': https://www.trainingexperience.org/bundles/index/images/tx-orange.png 
      http-equiv: 
       'Content-Type':   text/html; charset=utf-8 
     head: 
      'xmlns':    http://www.w3.org/1999/xhtml 
      'xmlns:og':   http://opengraphprotocol.org/schema/ 

cmf_seo: 
    title: seo.title 
    description: seo.description 
    sitemap: 
     enabled: true 
    content_listener: 
     enabled: false 

を追加しましたルートrouting.ymlへ:私は/sitemaps/sitemap.xmlにアクセスしたときに今

sitemaps: 
    prefix: /sitemaps 
    resource: "@CmfSeoBundle/Resources/config/routing/sitemap.xml" 

は、それが開かれ、ないていますURLが表示されます:

<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml"></urlset> 

どうすればよいですか?

+0

修正しましたか? – breq

答えて

0

重要なのは、サイトマップのアイテムに、一致する(許可されたサイトマップ名)がコンテンツとしてあることです。ほとんどの場合、コンテンツは読み込まれません。これを行うには、コンテンツに\Symfony\Cmf\Bundle\SeoBundle\SitemapAwareInterfaceを実装する必要があります。これにより、フラグを実装して入力する必要があります。あなたは、テストの例を見つけることができます:SitemapAwareContent

<?php 

/* 
* This file is part of the Symfony CMF package. 
* 
* (c) 2011-2017 Symfony CMF 
* 
* For the full copyright and license information, please view the LICENSE 
* file that was distributed with this source code. 
*/ 

namespace Symfony\Cmf\Bundle\SeoBundle\Tests\Resources\Document; 

use Doctrine\Common\Collections\ArrayCollection; 
use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; 
use Symfony\Cmf\Bundle\CoreBundle\Translatable\TranslatableInterface; 
use Symfony\Cmf\Bundle\SeoBundle\SitemapAwareInterface; 
use Symfony\Cmf\Component\Routing\RouteReferrersReadInterface; 
use Symfony\Component\Routing\Route; 

/** 
* @PHPCRODM\Document(referenceable=true, translator="attribute") 
* 
* @author Maximilian Berghoff <[email protected]> 
*/ 
class SitemapAwareContent extends ContentBase implements RouteReferrersReadInterface, TranslatableInterface, SitemapAwareInterface 
{ 
    /** 
    * @var string 
    * 
    * @PHPCRODM\Locale 
    */ 
    protected $locale; 

    /** 
    * @var ArrayCollection|Route[] 
    * 
    * @PHPCRODM\Referrers(
    * referringDocument="Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr\Route", 
    * referencedBy="content" 
    *) 
    */ 
    protected $routes; 

    /** 
    * @var bool 
    * 
    * @PHPCRODM\Field(type="boolean",property="visible_for_sitemap") 
    */ 
    private $isVisibleForSitemap; 

    /** 
    * @var string 
    * 
    * @PHPCRODM\Field(type="string",translated=true) 
    */ 
    protected $title; 

    public function __construct() 
    { 
     $this->routes = new ArrayCollection(); 
    } 

    /** 
    * @param string $sitemap 
    * 
    * @return bool 
    */ 
    public function isVisibleInSitemap($sitemap) 
    { 
     return $this->isVisibleForSitemap; 
    } 

    /** 
    * @param bool $isVisibleForSitemap 
    * 
    * @return SitemapAwareContent 
    */ 
    public function setIsVisibleForSitemap($isVisibleForSitemap) 
    { 
     $this->isVisibleForSitemap = $isVisibleForSitemap; 

     return $this; 
    } 

    /** 
    * Add a route to the collection. 
    * 
    * @param Route $route 
    */ 
    public function addRoute($route) 
    { 
     $this->routes->add($route); 
    } 

    /** 
    * Remove a route from the collection. 
    * 
    * @param Route $route 
    */ 
    public function removeRoute($route) 
    { 
     $this->routes->removeElement($route); 
    } 

    /** 
    * Get the routes that point to this content. 
    * 
    * @return Route[] Route instances that point to this content 
    */ 
    public function getRoutes() 
    { 
     return $this->routes; 
    } 

    /** 
    * @return string|bool the locale of this model or false if 
    *      translations are disabled in this project 
    */ 
    public function getLocale() 
    { 
     return $this->locale; 
    } 

    /** 
    * @param string|bool $locale the local for this model, or false if 
    *       translations are disabled in this project 
    */ 
    public function setLocale($locale) 
    { 
     $this->locale = $locale; 
    } 
} 

また、あなたはまた、教義のマッピングを設定する必要があり、インターフェイスを実装する唯一のタスクではないことがわかります。そうすることで、デフォルトのローダがドキュメントを取得して表示します(現在表示されています)。 しかし、独自のローダ、投票者(選択する別のデシジョンアイテム)、および推測者(余分なデータを記入する)を自分で実装することができます。したがって、どのコンテンツが(いくつかのサイトマップを持つことができる)表示可能なコンテンツを決定することができます。

にはローダー、投票者、および推測者のプロセスのみが表示されるため、既定の表示フラグとデフォルトの使用方法についてのヒントを挿入する必要があります。そこで私はissueを作成しました。そこにもいくつかのフィードバックを得るのは良いことです。

関連する問題