do not show translated category ids in list
authorAlan Knowles <alan@roojs.com>
Wed, 3 Jun 2020 09:02:19 +0000 (17:02 +0800)
committerAlan Knowles <alan@roojs.com>
Wed, 3 Jun 2020 09:02:19 +0000 (17:02 +0800)
DataObjects/Cms_page_category.php
mysql/cms_page_fullpath.sql

index 620a9cf..171c460 100644 (file)
@@ -44,7 +44,7 @@ class Pman_Cms_DataObjects_Cms_page_category  extends DB_DataObject
         $sub = array(
             'page' => array(),
             'blog' => array()
-        );
+        ); 
         
         $cms_page_category->selectAdd();
         $cms_page_category->selectAdd("
@@ -54,6 +54,8 @@ class Pman_Cms_DataObjects_Cms_page_category  extends DB_DataObject
                 join_page_id_id.page_type_id as page_id_page_type_id 
                                       
         ");
+        $cms_page_category->whereAdd('join_category_id_id.translation_of_id = 0');
+        
         $cms_page_category->groupBy("
             cms_page_category.category_id,
             join_category_id_id.is_draft,
index 882a495..08e3614 100644 (file)
@@ -5,7 +5,8 @@ DELIMITER $$
 
 CREATE PROCEDURE cms_page_fullpath(
     IN in_id INT(11), 
-    IN in_separator VARCHAR(64), 
+    IN in_separator VARCHAR(64),
+    IN in_depth INT(11),
     OUT fullpath TEXT 
 ) DETERMINISTIC
     BEGIN
@@ -19,18 +20,18 @@ CREATE PROCEDURE cms_page_fullpath(
         SET v_parent_title = '';
         SET v_parent_id = 0;
         SET v_translation_of_id = 0;
-        SET max_sp_recursion_depth = 255;
-
+        SET max_sp_recursion_depth = 15;
+        
         SELECT title, parent_id, translation_of_id INTO v_title, v_parent_id, v_translation_of_id FROM cms_page WHERE id = in_id;
 
         IF (v_translation_of_id > 0) THEN
             SELECT title, v_parent_id INTO v_title, v_parent_id FROM cms_page WHERE id = v_translation_of_id;
         END IF;
 
-        IF (v_parent_id = 0) THEN
+        IF (v_parent_id = 0 OR in_depth > 10) THEN
             SET fullpath = v_title;
         ELSE
-            CALL cms_page_fullpath(v_parent_id, in_separator, v_parent_title);
+            CALL cms_page_fullpath(v_parent_id, in_separator, in_depth + 1, v_parent_title);
 
             SELECT CONCAT_WS(in_separator, v_parent_title, v_title) INTO fullpath;
         END IF;
@@ -51,7 +52,7 @@ RETURNS TEXT DETERMINISTIC
         
         DECLARE v_ret TEXT;
 
-        CALL cms_page_fullpath(in_id, in_separator, v_ret);
+        CALL cms_page_fullpath(in_id, in_separator, 0,  v_ret) ;
 
         RETURN v_ret;