Skip to content

Commit a6cb0d2

Browse files
committed
Changed posts to post alia for taxonomy queries and categories component
1 parent f48b8ad commit a6cb0d2

File tree

7 files changed

+40
-20
lines changed

7 files changed

+40
-20
lines changed

admin/sql/mysqli/category.sql

+1-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@
172172
LEFT JOIN post p ON (pc.post_id = p.post_id)
173173
LEFT JOIN post_to_taxonomy_item ptt ON (ptt.taxonomy_item_id = @taxonomy_item_id AND ptt.post_id = p.post_id)
174174
WHERE ptt.taxonomy_item_id = @taxonomy_item_id ORDER by p.sort_order
175-
) AS posts
175+
) AS post
176176

177177
FROM taxonomy_item AS categories
178178

admin/sql/mysqli/menu.sql

+13-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
-- Menus
2-
2+
33
-- get menu
44

55
CREATE PROCEDURE getMenu(
@@ -96,8 +96,6 @@
9696
IN language_id INT,
9797
IN menu_id INT,
9898
IN site_id INT,
99-
IN post_id INT,
100-
IN search CHAR,
10199
IN type CHAR,
102100

103101
-- pagination
@@ -113,11 +111,20 @@
113111

114112
SELECT *, menu.menu_id as array_key
115113

116-
FROM menu
114+
FROM menu
115+
116+
@IF isset(:menu_id)
117+
THEN
118+
WHERE menu.menu_id IN (:menu_id)
119+
END @IF
120+
121+
-- limit
122+
@IF isset(:limit)
123+
THEN
124+
@SQL_LIMIT(:start, :limit)
125+
END @IF;
117126

118127

119-
@SQL_LIMIT(:start, :limit);
120-
121128
SELECT count(*) FROM (
122129

123130
@SQL_COUNT(menu.menu_id, menu) -- this takes previous query removes limit and replaces select columns with parameter menu_id

admin/sql/pgsql/category.sql

+1-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@
171171
LEFT JOIN post p ON (pc.post_id = p.post_id)
172172
LEFT JOIN post_to_taxonomy_item ptt ON (ptt.taxonomy_item_id = categories.taxonomy_item_id AND ptt.post_id = p.post_id)
173173
WHERE ptt.taxonomy_item_id = categories.taxonomy_item_id ORDER by p.sort_order
174-
) AS posts
174+
) AS post
175175

176176
FROM taxonomy_item AS categories
177177

admin/sql/pgsql/menu.sql

+10-3
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,6 @@
9696
IN language_id INT,
9797
IN menu_id INT,
9898
IN site_id INT,
99-
IN post_id INT,
100-
IN search CHAR,
10199
IN type CHAR,
102100

103101
-- pagination
@@ -115,8 +113,17 @@
115113

116114
FROM menu
117115

116+
@IF isset(:menu_id)
117+
THEN
118+
WHERE menu.menu_id IN (:menu_id)
119+
END @IF
118120

119-
@SQL_LIMIT(:start, :limit);
121+
-- limit
122+
@IF isset(:limit)
123+
THEN
124+
@SQL_LIMIT(:start, :limit)
125+
END @IF;
126+
120127

121128
SELECT count(*) FROM (
122129

admin/sql/sqlite/category.sql

+1-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@
171171
LEFT JOIN post p ON (pc.post_id = p.post_id)
172172
LEFT JOIN post_to_taxonomy_item ptt ON (ptt.taxonomy_item_id = categories.taxonomy_item_id AND ptt.post_id = p.post_id)
173173
WHERE ptt.taxonomy_item_id = categories.taxonomy_item_id ORDER by p.sort_order
174-
) AS posts
174+
) AS post
175175

176176
FROM taxonomy_item AS categories
177177

admin/sql/sqlite/menu.sql

+10-3
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,6 @@
9696
IN language_id INT,
9797
IN menu_id INT,
9898
IN site_id INT,
99-
IN post_id INT,
100-
IN search CHAR,
10199
IN type CHAR,
102100

103101
-- pagination
@@ -115,8 +113,17 @@
115113

116114
FROM menu
117115

116+
@IF isset(:menu_id)
117+
THEN
118+
WHERE menu.menu_id IN (:menu_id)
119+
END @IF
118120

119-
@SQL_LIMIT(:start, :limit);
121+
-- limit
122+
@IF isset(:limit)
123+
THEN
124+
@SQL_LIMIT(:start, :limit)
125+
END @IF;
126+
120127

121128
SELECT count(*) FROM (
122129

app/component/categories/pages.php

+4-5
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ function results() {
5858

5959
break;
6060
}
61-
6261
//count the number of child categories (subcategories) for each category
6362
if (isset($results['categories'])) {
6463
foreach ($results['categories'] as $taxonomy_item_id => &$category) {
@@ -74,11 +73,11 @@ function results() {
7473
$category['children'] = 0;
7574
}
7675

77-
if (isset($category['posts']) && $category['posts'] && $category['posts'][0] = '[') {
78-
$category['posts'] = json_decode($category['posts'], true);
76+
if (isset($category['post']) && $category['post'] && $category['post'][0] = '[') {
77+
$category['post'] = json_decode($category['post'], true);
7978

80-
if (is_array($category['posts'])) {
81-
$category['posts_count'] = count($category['posts']);
79+
if (is_array($category['post'])) {
80+
$category['posts_count'] = count($category['post']);
8281
}
8382
}
8483

0 commit comments

Comments
 (0)