General Community > Development 2.10.x
Root Parent IDs of Root Pages
gokcer:
I was trying a custom menu function working with root parent IDs and noticed an inconsistency.
A newly added page's root parent ID is set to its page id if it has no parents (level 0).
Go to page settings, set the new page as a child page of any page and save. (As expected the root parent ID is now set to the parent page's root parent ID)
But when you rollback to the previous state (move the new page to the root again), this time the root parent ID is set to 0.
Probably default functions are not affected by this problem, but my custom menu function gets broken when a root page's root parent ID is set to 0 with the changes on the page tree.
Problem is the code below that sets root_parent ID to 0, if parent ID is 0.
admin/pages/settings2.php (line 193):
--- Code: ---$level = '0';
$root_parent = '0';
if ($parent!='0'){
$level = level_count($parent)+1;
$root_parent = root_parent($parent);
}
--- End code ---
Added the lines below to fix this, and now it works:
admin/pages/settings2.php (after line 198):
--- Code: ---else {
$root_parent = $page_id;
}
--- End code ---
This (or a better solution) may be useful for the possible developments on the menu functions.
The correctness of this fix is depending on the question what must be the default root parent ID of a new page. If it must be 0, a different fix must be applied to set the newly added root pages' root parent IDs to 0.
But I think root pages' root parent IDs must be set to the page IDs for more functionality, because there is the "parent" field if we need a "0" on detections.
DarkViper:
a little explanation:
ROOT_PARENT
for pages on level = 0 the root_parent always is '0' (no parent available)
all pages on all other levels get the page_id from level '0' in their tree
PARENT:
each page with level >0 there have the id of its parent page (level -1).
each page with level =0 there have the '0' (no parent available)
unsorted example:page_idlevelroot_parentparentpage_trailposition10001221111,2231111,3142121,2,4150005161555,6172565,6,71The resulting sorted page tree:
5 :: '/pages/page_5.php'
- 6 :: '/pages/page_5/page_6.php'
- - 7 :: '/pages/page_5/page_6/page_7.php'
1 :: '/pages/page_1.php'
- 3 :: '/pages/page_1/page_3.php'
- 2 :: '/pages/page_1/page_2.php'
- - 4 :: '/pages/page_1/page_2/page_4.php'
All evaluation of the page tree is based exactly on this system and works fine since about 13 years.
All changes in this system must be also adapted to all places in the core and all modules to avoid undesirable side effects.
For the version series 2.x.x no change is planned in this system. Only with the next main version a completely new system becomes built up.
But from my tests during last days i located a real issue concerning the SEO links. Am working on to solve this problem asap.
Manuela
dbs:
--- Quote ---But from my tests during last days i located a real issue concerning the SEO links. Am working on to solve this problem asap.
--- End quote ---
Nice to read that. (Y)
gokcer:
Hi Manuela,
Thank you for the explanation.
Maybe I couldn't understand and also couldn't explain the problem exactly because of my terrible English.
--- Quote ---for pages on level = 0 the root_parent always is '0'
--- End quote ---
Ok, but:
When I add a page to the root, the ROOT PARENT is the PAGE ID inside database's root_parent column. (Not "0")
If I go to the page settings and save it without changing anything, the ROOT PARENT becomes "0" inside database.
Don't you think there must be a fix to make the root page's ROOT PARENTS "0" at the time they are added?
Below the lines of "function root_parent" (framework/functions.php: 479) which make ROOT PARENT equal to PAGE ID, when called form admin/pages/add.php (196) with "$root_parent = root_parent($page_id);"
--- Code: ---}elseif($parent == 0) {
return $page_id;
}
--- End code ---
But in admin/pages/settings2.php (lines 193-198) ROOT PARENT is defined as "0" and the function is called only if the PARENT is not equal to 0.
As I understand from your explanation, "settings2.php" works correct on ROOT PARENT ids, because it sets the ROOT PARENT to 0 for LEVEL 0.
But "add.php" doesn't.
Gast:
--- Quote ---When I add a page to the root, the ROOT PARENT is the PAGE ID inside database's root_parent column. (Not "0")
--- End quote ---
very simple ;-)
problem is different code for different actions in different files
- if i add a new page in the root of my page tree, this page has no parent (PARENT is 0) and also no root parent (ROOT PARENT is PAGE_ID)
- if i add a child for this page, this page get the root parent from the parent in this tree
vs.
- if i change the parent of a child, the script rewrite a new page_trail and set the ROOT_PARENT to 0
- if i change the seo-title, the function root_parent() works and rewrite the root_parent of this page to 0
maybe its simple forgotten in all the years, i dont know. i dont remember in all this years, that somebody reported a problem with this. i found this problem in my test's, because my menu doesnt work. the error is reported on the project page and i think, with a good description, so i'm sure, the solution for that come's with the next version
thats the important words for me
--- Quote from: DarkViper ---But from my tests during last days i located a real issue concerning the SEO links. Am working on to solve this problem asap.
--- End quote ---
dont know, if we talk about the same issue here or not, but i'm sure, the complete process to add pages, change parents or seo-links get a new code and a working solution without questions. then we test again :wink:
Navigation
[0] Message Index
[#] Next page
Go to full version