Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [Symfony]i18n i kategorie
Forum PHP.pl > Forum > PHP > Frameworki
trucksweb
mam problem bo juz nie wiem w czym szukac.

Robilem wczesniej wielojezykowy projekt i wydaje mi sie, ze tak samo przeprowadzilem obecnie procedure:
mam tabele:
category (klucz glowny na id_cat)
category_i18n (klucz glowny na id_cat i culture)

robie teraz zapytanie:

  1. $c = new Criteria();
  2. $c->addAscendingOrderByColumn(CategoryPeer::ID_PARENT);
  3. $c->addJoin(CategoryI18nPeer::ID_CATEGORY, CategoryPeer::ID_CATEGORY);
  4. $c->add(CategoryI18nPeer::CULTURE, 'pl_PL');
  5. $categories = CategoryPeer::doSelect($c);


potrzebuje tego tylko tlumaczenia polskiego do spisu na poziomie admina.

teraz w szablonie:
  1. foreach($categories as $cat)
  2. echo $cat->getName()


wywala blad:
Cytat
Call to undefined method BaseCategory::getName



czemu?
destroyerr
Potrzebujemy poznać jeszcze Twój schemat.
trucksweb
opisalem co sie znjaduje w tabelach ale jak to tak potrzebne to prosze:

  1. category:
  2. _attributes:
  3. idMethod: native
  4. isI18n: true
  5. i18nTable: category_i18n
  6. id_category:
  7. type: INTEGER
  8. required: true
  9. autoIncrement: true
  10. primaryKey: true
  11. id_parent:
  12. type: INTEGER
  13. required: false
  14. unsigned: true
  15. foreignTable: category
  16. foreignReference: id_category
  17. onDelete: RESTRICT
  18. onUpdate: RESTRICT
  19. ip:
  20. type: VARCHAR
  21. size: 1024
  22. required: false
  23. depth:
  24. type: INTEGER
  25. required: false
  26. description:
  27. type: VARCHAR
  28. size: 4096
  29. created_at: { type: timestamp }
  30. updated_at: { type: timestamp }
  31.  
  32. category_i18n:
  33. _attributes:
  34. idMethod: native
  35. id_category:
  36. type: INTEGER
  37. required: true
  38. primaryKey: true
  39. foreignTable: category
  40. foreignReference: id_category
  41. culture:
  42. isCulture: true
  43. type: VARCHAR
  44. size: 7
  45. required: true
  46. primaryKey: true
  47. name:
  48. type: VARCHAR
  49. size: 1024
  50. required: true
  51. seo_name:
  52. type: VARCHAR
  53. size: 1024
  54. required: true
destroyerr
Opisałeś co się znajduje w tabelach, ale nie napisałeś nic na temat konfiguracji i18n dlatego chciałem zobaczyć schemat. To co znajduje się w tabelach opisałeś źle, tak samo jak zły jest schemat. Tabela category nie zawiera kolumny id_category, a powinna. Jeśli to nie rozwiązało problemu, to może on jeszcze leżeć w konfiguracji behaviors.
trucksweb
fakt, poprawilem ale to nie w tym problem.

wszystko robie tak jak jest w dokumentacji
http://www.symfony-project.org/jobeet/1_4/Propel/en/19

a nie dziala u mnie takie cos:

  1. $category = new JobeetCategory();
  2. $category->setName('foo'); // sets the name for the current culture
  3. echo $category->getName(); // gets the name for the current culture




ponizej jeszcze wklejam konfiguracje i18n.yml

helper dodanych do ogolnych



  1. all:
  2. i18n:
  3. class: sfI18N
  4. param:
  5. source: MySQL
  6. database: mysql://root:@localhost/katalog
  7. default_culture: pl_PL
  8. debug: true
  9. untranslated_prefix: "[T]"
  10. untranslated_suffix: "[/T]"
  11. cache:
  12. class: sfFileCache
  13. param:
  14. automatic_cleaning_factor: 0
  15. cache_dir: %SF_I18N_CACHE_DIR%
  16. lifetime: 31556926
  17. prefix: %SF_APP_DIR%/i18n
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.