sql - TYPO3 get pages by sys_categor(y/ies) -
i need help, not see forest trees. consider following scenario:
a typo3 - system with, say, 2 pages. (about & services) furthermore, have 3 system categories (cat 1, cat 2 cat 3)
the page us, categories "cat 1" & "cat 2". page services has categories "cat 2" & "cat 3".
now need select query in typoscript page "cat 3" , "cat 2 (in case page services).
but let's start simple sql , not typoscript query.
the following 3 tables exist in typo3 situation:
"pages", "sys_category", "sys_category_record_mm"
pages - table: +-----+----------+------------+ | uid | title | categories | +-----+----------+------------+ | 3 | | 2 | | 4 | services | 2 | +-----+----------+------------+ sys_category - table: +-----+-------+ | uid | title | +-----+-------+ | 1 | cat 1 | | 2 | cat 2 | | 3 | cat 3 | +-----+-------+ sys_category_record_mm - table: +-----------+-------------+------------+ | uid_local | uid_foreign | tablenames | +-----------+-------------+------------+ | 2 | 4 | pages | | 2 | 3 | pages | | 1 | 4 | pages | | 3 | 3 | pages | +-----------+-------------+------------+
now have simple sql query outputs pages got category, this:
select distinct title pages join sys_category_record_mm on sys_category_record_mm.uid_foreign = pages.uid sys_category_record_mm.tablenames = 'pages'
this me following output:
+----------+ | title | +----------+ | services | | | +----------+
but want have page "services" has category "cat 2" , category "cat 3".
how have modify query page both categories.
i tried know can't work, because still both pages because of or condition.
select distinct title pages join sys_category_record_mm on sys_category_record_mm.uid_foreign = pages.uid sys_category_record_mm.tablenames = 'pages' , (sys_category_record_mm.uid_local = 2 or sys_category_record_mm.uid_local = 3)
thanks in advance!!
i'm thankful every tip.
thanks marcus schwemer, pointed me solutions.. pgampe answer!
i've done categories menu. marcus said: "each in resulting array of pages gets additional entry key _categories containing list of categories page belongs to, comma-separated list of uid’s. can accessed stdwrap.field or gettext other field."
its easy if condition in menu like:
20 = hmenu 20 { special = categories # show pages categories 1, 2 , 3 special.value = 1,2,3 1 = tmenu 1.no { # comma-separated list of uid's of categories page belongs stdwrap.field = _categories # check _categories field if contains categories need. stdwrap.if { value = 2,3 equals.field = _categories } } }
that's all...
Comments
Post a Comment