Buduje w symfony system artykułów. Strona na której będą umieszczane będzie w różnych językach, i każdy język musi mieć kompletnie inny zbiór artykułów. Dodatkowo, tytuły ( w moim schemacie tytuł to jest headline ) mogą się w różnych językach powtarzać. Jak powinienem zbudować schemat takiej tabeli? Zrobiłem tak, jak niżej ale może w symfony są jakieś inne zalecenia?
CODE
JbArticle:
actAs:
Timestampable: ~
Sluggable:
fields: [ headline ]
uniqueBy: [ headline, lang ]
columns:
writer_id: { type: integer }
title: { type: string(150), notnull: true }
description: { type: string(500), notnull: true }
keywords: { type: string(255) }
headline: { type: string(80), notnull: true }
content: { type: string(10000), notnull: true }
redirection: { type: string(255) }
additional_scripts: { type: string(2000) }
is_main: { type: boolean, notnull: true, default: 0 }
is_disabled: { type: boolean, notnull: true, default: 0 }
is_finished: { type: boolean, notnull: true, default: 0 }
is_published: { type: boolean, notnull: true, default: 0 }
is_tested: { type: boolean, notnull: true, default: 0 }
is_hittail: { type: boolean, notnull: true, default: 0 }
is_review: { type: boolean, notnull: true, default: 0 }
lang: { type: string(2), notnull: true, fixed: true }
indexes:
name_lang:
fields: [ headline, lang ]
relations:
JbUser: { onDelete: SET NULL, local: writer_id, foreign: id, foreignAlias: JbArticles }
actAs:
Timestampable: ~
Sluggable:
fields: [ headline ]
uniqueBy: [ headline, lang ]
columns:
writer_id: { type: integer }
title: { type: string(150), notnull: true }
description: { type: string(500), notnull: true }
keywords: { type: string(255) }
headline: { type: string(80), notnull: true }
content: { type: string(10000), notnull: true }
redirection: { type: string(255) }
additional_scripts: { type: string(2000) }
is_main: { type: boolean, notnull: true, default: 0 }
is_disabled: { type: boolean, notnull: true, default: 0 }
is_finished: { type: boolean, notnull: true, default: 0 }
is_published: { type: boolean, notnull: true, default: 0 }
is_tested: { type: boolean, notnull: true, default: 0 }
is_hittail: { type: boolean, notnull: true, default: 0 }
is_review: { type: boolean, notnull: true, default: 0 }
lang: { type: string(2), notnull: true, fixed: true }
indexes:
name_lang:
fields: [ headline, lang ]
relations:
JbUser: { onDelete: SET NULL, local: writer_id, foreign: id, foreignAlias: JbArticles }
Pojawia się tutaj problem z routingiem, URLe mają wyglądać tak:
/pl/przewodnik/tytul
/guide/tytul
czyli dla angielskiego, język nie ma się pojawiać w urlu, ale jak wtedy pobrać artykul? To co ja mam nie może działać, bo nie ma w roucie 'guide' zmiennej 'lang'.
CODE
guide:
url: /guide/:slug
class: sfDoctrineRoute
options: { model: JbArticle, type: object }
param: { module: article, action: show }
requirements: { lang: en }
przewodnik:
url: /:lang/przewodnik/:slug
class: sfDoctrineRoute
options: { model: JbArticle, type: object }
param: { module: article, action: show }
requirements: { lang: pl }
url: /guide/:slug
class: sfDoctrineRoute
options: { model: JbArticle, type: object }
param: { module: article, action: show }
requirements: { lang: en }
przewodnik:
url: /:lang/przewodnik/:slug
class: sfDoctrineRoute
options: { model: JbArticle, type: object }
param: { module: article, action: show }
requirements: { lang: pl }
Dzięki za pomoc!
pozdrawiam