WebsiteBaker Logo
  • *
  • Templates
  • Help
  • Add-ons
  • Download
  • Home
*
Welcome, Guest. Please login or register.

Login with username, password and session length
 

News


WebsiteBaker 2.13.6 is now available!


Will it continue with WB? It goes on! | Geht es mit WB weiter? Es geht weiter!
https://forum.websitebaker.org/index.php/topic,32340.msg226702.html#msg226702


The forum email address board@websitebaker.org is working again
https://forum.websitebaker.org/index.php/topic,32358.0.html


R.I.P Dietmar (luisehahne) and thank you for all your valuable work for WB
https://forum.websitebaker.org/index.php/topic,32355.0.html


* Support WebsiteBaker

Your donations will help to:

  • Pay for our dedicated server
  • Pay for domain registration
  • and much more!

You can donate by clicking on the button below.


  • Home
  • Help
  • Search
  • Login
  • Register

  • WebsiteBaker Community Forum »
  • General Community »
  • Development 2.10.x »
  • Link & location of a new or moved subpage after its parent's seo-title changed
  • Print
Pages: [1]   Go Down

Author Topic: Link & location of a new or moved subpage after its parent's seo-title changed  (Read 12292 times)

Offline gokcer

  • Posts: 94
Link & location of a new or moved subpage after its parent's seo-title changed
« on: July 15, 2017, 02:31:12 AM »
After the seo-title of a parent page is changed without changing the menu title:
When a new sub page added (or moved) under it, old seo-title (which generated from its title) is set as the folder name inside the subpage's link and location. Because the folder names in link tree is generated with titles. This causes different folders for the siblings under pages directory.

Why don't we use the parent link for a more correct structure?
(This may also be related to http://project.WebsiteBaker.org/issues/37)

Please warn me if I am wrong (inside admin/pages/add.php-121 and admin/pages/settings2.php-220):

Code: [Select]
/* comment out old code that generate links from parent titles
        $parent_section = '';
        $parent_titles = array_reverse(get_parent_titles($parent));
        foreach($parent_titles AS $parent_title) {
                $parent_section .= page_filename($parent_title).'/';
        }
        if($parent_section == '/') { $parent_section = ''; }
        $link = '/'.$parent_section.page_filename($title); // -> this is ($seo_title) for settings2.php
*/
// new code to get parent link and put inside the sub page link
        $sql = 'SELECT `link` FROM `'.TABLE_PREFIX.'pages` WHERE `page_id` = '.intval($parent);
        $parent_link = $database->get_one($sql);
        $parent_section =  $parent_link.'/';
        if($parent_section == '/') { $parent_section = ''; }
        $link = $parent_section.page_filename($title); -> this is ($seo_title) for settings2.php

Logged

Offline jacobi22

  • Betatester
  • **
  • Posts: 5920
Re: Link & location of a new or moved subpage after its parent's seo-title changed
« Reply #1 on: July 15, 2017, 01:12:07 PM »
my private position.... the problem is reported (your link to the project) and i'll wait for a official solution for that

i test your code, but if add a new subpage to a renamed parent, it add's this page into the root of the page directory - so something goes wrong  :|

Logged

Offline gokcer

  • Posts: 94
Re: Link & location of a new or moved subpage after its parent's seo-title changed
« Reply #2 on: July 15, 2017, 10:17:26 PM »
Thanks for testing.
Everything looks ok on my tests, but I found a "double slashes" problem on the code which may cause the problem on your server so I renewed it.
And I tested it with the following data:
Parent page's menu title: "Parent Page"
Parent page's changed seo title: "new_seo_name"
Sub page's title: "Sub Page"

admin/pages/add.php (121) (results near lines):

Code: [Select]
/* comment out old code that generate links from parent titles
        $parent_section = '';
        $parent_titles = array_reverse(get_parent_titles($parent));
        foreach($parent_titles AS $parent_title)
        {
                $parent_section .= page_filename($parent_title).'/';
        }
        if($parent_section == '/') { $parent_section = ''; }
        $link = '/'.$parent_section.page_filename($title);
        $filename = WB_PATH.PAGES_DIRECTORY.'/'.$link.PAGE_EXTENSION;
        make_dir(WB_PATH.PAGES_DIRECTORY.'/'.$parent_section);
*/
// the fix
        $sql = 'SELECT `link` FROM `'.TABLE_PREFIX.'pages` WHERE `page_id` = '.intval($parent);
        $parent_link = $database->get_one($sql); // -----> "/new_seo_name"
        $link = $parent_link.'/'.page_filename($title);//  -----> "/new_seo_name/sub-page" (this one goes to database)
        $filename = WB_PATH.PAGES_DIRECTORY.$link.PAGE_EXTENSION; // -----> "[WB_PATH]pages/new_seo_name/sub-page.php"
        make_dir(WB_PATH.PAGES_DIRECTORY.$parent_link); // -----> "[WB_PATH]pages/new_seo_name"
// end fix

admin/pages/settings2.php (220):
Code: [Select]
/* comment out old code that generate links from parent titles
        $parent_section = '';
        $parent_titles = array_reverse(get_parent_titles($parent));
        foreach($parent_titles as $parent_title) {
                $parent_section .= page_filename($parent_title).'/';
        }
        if( $parent_section == '/' ) { $parent_section = ''; }
        $link = '/'.$parent_section.page_filename($seo_title);
        $filename = WB_PATH.PAGES_DIRECTORY.'/'.$parent_section.page_filename($seo_title).PAGE_EXTENSION;
*/
// the fix
$sql = 'SELECT `link` FROM `'.TABLE_PREFIX.'pages` WHERE `page_id` = '.intval($parent);
        $parent_link = $database->get_one($sql);
        $link = $parent_link.'/'.page_filename($seo_title);
        $filename = WB_PATH.PAGES_DIRECTORY.$parent_link.'/'.page_filename($seo_title).PAGE_EXTENSION;
// end fix
Logged

Offline DarkViper

  • Forum administrator
  • *****
  • Posts: 3087
  • Gender: Female
Re: Link & location of a new or moved subpage after its parent's seo-title changed
« Reply #3 on: July 20, 2017, 06:30:25 PM »
see Re: Root Parent IDs of Root Pages
Logged
Der blaue Planet - er ist nicht unser Eigentum - wir haben ihn nur von unseren Nachkommen geliehen

"We need education to cope with digitalization - and NOT the digitalization of education.!"

Tägliches Stoßgebet: Oh Herr, wirf Hirn vom Himmel !

  • Print
Pages: [1]   Go Up
  • WebsiteBaker Community Forum »
  • General Community »
  • Development 2.10.x »
  • Link & location of a new or moved subpage after its parent's seo-title changed
 

  • SMF 2.0.19 | SMF © 2017, Simple Machines
  • XHTML
  • RSS
  • WAP2