Author Topic: Root Parent IDs of Root Pages  (Read 320 times)

Offline gokcer

  • Posts: 94
Root Parent IDs of Root Pages
« on: July 08, 2017, 02:32:02 PM »
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:
Only registered users can see contents. Please click here to Register or Login.
Added the lines below to fix this, and now it works:

admin/pages/settings2.php (after line 198):
Code:
Only registered users can see contents. Please click here to Register or Login.
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.

Offline DarkViper

  • Core Development
  • *****
  • Posts: 2851
  • Gender: Female
Re: Root Parent IDs of Root Pages
« Reply #1 on: July 19, 2017, 11:24:45 AM »
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_trailposition
100012
21111,22
31111,31
42121,2,41
500051
61555,61
72565,6,71
The 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



« Last Edit: July 19, 2017, 11:41:22 AM by DarkViper »
Der blaue Planet - er ist nicht unser Eigentum - wir haben ihn nur von unseren Nachkommen geliehen

"You have to take the men as they are ... but you can not leave them like that !!" :-P
Ein einziger Buchstabendreher kann einen ganzen Satz urinieren.

Offline dbs

  • Betatester
  • **
  • Posts: 6921
  • Gender: Male
  • tioz4ever
    • WebsiteBaker - jQuery-Plugins - Module - Droplets - Tests
Re: Root Parent IDs of Root Pages
« Reply #2 on: July 19, 2017, 12:07:15 PM »
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.
Nice to read that.  (Y)

Offline gokcer

  • Posts: 94
Re: Root Parent IDs of Root Pages
« Reply #3 on: July 23, 2017, 02:52:10 PM »
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'

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:
Only registered users can see contents. Please click here to Register or Login.
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.

Offline jacobi22

  • Global Moderator
  • *****
  • Posts: 4454
  • Gender: Male
    • Jacobi22
Re: Root Parent IDs of Root Pages
« Reply #4 on: July 23, 2017, 05:01:38 PM »
Quote
When I add a page to the root, the ROOT PARENT is the PAGE ID inside database's root_parent column. (Not "0")

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.
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:
Du bist der Mensch, der mich zum Lachen bringt und der, der mit mir weint. Ich muss lachen, wenn du lachst und weinen, wenn du weinst und darum wirst du für immer ein Teil von meinem Herzen sein
(*miss you*)

Offline gokcer

  • Posts: 94
Re: Root Parent IDs of Root Pages
« Reply #5 on: July 23, 2017, 05:28:55 PM »
Quote
very simple  ;-)
problem is different code for different actions in different files

Thanks jacobi :)

The seo-title problem is not the same issue with this, but I don't know why that topic was locked after Manuela referred here.