WebsiteBaker Community Forum

WebsiteBaker Support (2.8.x) => Droplets & Snippets => Topic started by: danfuh on November 24, 2006, 10:08:46 PM

Title: Search Engine Friendly URL, differently to the link name
Post by: danfuh on November 24, 2006, 10:08:46 PM
Hello

first of all, sorry for my bad english.
I would like that my URL is different to the menu link.
Currently, the menu entry link is Gästebuch and the URL is  gE4stebuch.html
I would that the URL is named gaestebuch.html

Is there any solution to arrange the URL different to the menu name?
It is no problem to change this inside the database, but I would like to handle this in the admin-backend.

Thank you in advance,

Daniel
Title: Re: Search Engine Friendly URL, differently to the link name
Post by: kweitzel on November 24, 2006, 10:16:18 PM
have a look into the file "convert(.)php", this is the conversion chart for these special characters ... by editing this file you can write your own rewriting conventions.

cheers

Klaus
Title: Re: Search Engine Friendly URL, differently to the link name
Post by: danfuh on November 24, 2006, 10:46:10 PM
Thank You,

I try to change
settings.php
settings.html
and
settings2.php

If i would have a additional input form for every page, i can change the URL and filename total different to the menu link.
Like this:
menu link: Home -> contact -> disclaimer
URL: http://mysite.com/disclaimer.html

when i've finished the source-code changes, i will port my solution here.
Title: Re: Search Engine Friendly URL, differently to the link name
Post by: danfuh on November 24, 2006, 11:20:17 PM
My solution is a new input form for every page, where you can change the URL/Filename different to the menulink.

(http://daniel.fuhrmannek.de/media/url.jpg)

I've done the following changes

inside the file /admin/pages/settings.php

approx. line 61
before:
Code: [Select]
// Get display name of person who last modified the page
$user=$admin->get_user_details($results_array['modified_by']);

after:
Code: [Select]
// Get display name of person who last modified the page
$user=$admin->get_user_details($results_array['modified_by']);

// Get Page Extension (Filename Suffix)
$database = new database();
$query = "SELECT * FROM ".TABLE_PREFIX."settings WHERE name = 'page_extension'";
$result = $database->query($query);
$result_array_extension = $result->fetchRow();

approx. line 82
before:
Code: [Select]
$template->set_var(array(
                                'PAGE_ID' => $results_array['page_id'],
                                'PAGE_TITLE' => ($results_array['page_title']),
                                'MENU_TITLE' => ($results_array['menu_title']),
                                'DESCRIPTION' => ($results_array['description']),
                                'KEYWORDS' => ($results_array['keywords']),
                                'MODIFIED_BY' => $user['display_name'],
                                'MODIFIED_BY_USERNAME' => $user['username'],
                                'MODIFIED_WHEN' => $modified_ts,
                                'ADMIN_URL' => ADMIN_URL
                                )
                         );

after:
Code: [Select]
$template->set_var(array(
                                'PAGE_ID' => $results_array['page_id'],
                                'PAGE_LINK' => ($results_array['link']),
                                'PAGE_EXTENSION' => ($result_array_extension['value']),
                                'PAGE_TITLE' => ($results_array['page_title']),
                                'MENU_TITLE' => ($results_array['menu_title']),
                                'DESCRIPTION' => ($results_array['description']),
                                'KEYWORDS' => ($results_array['keywords']),
                                'MODIFIED_BY' => $user['display_name'],
                                'MODIFIED_BY_USERNAME' => $user['username'],
                                'MODIFIED_WHEN' => $modified_ts,
                                'ADMIN_URL' => ADMIN_URL
                                )
                         );

inside the file /admin/pages/settings.html
approx. line 68 - 73

before:
Code: [Select]
<tr height="20">
        <td width="100" height="20">{TEXT_MENU_TITLE}:</td>
        <td with="240" height="20">
                <input type="text" name="menu_title" value="{MENU_TITLE}" style="width: 232px;" />
        </td>
</tr>

after:
Code: [Select]
<tr height="20">
        <td width="100" height="20">URL:</td>
        <td with="240" height="20">
                <input type="text" name="link" value="{PAGE_LINK}" style="width: 205px;" />{PAGE_EXTENSION}
        </td>
</tr>
<tr height="20">
        <td width="100" height="20">{TEXT_MENU_TITLE}:</td>
        <td with="240" height="20">
                <input type="text" name="menu_title" value="{MENU_TITLE}" style="width: 232px;" />
        </td>
</tr>

inside the file /admin/pages/settings2.php
approx. line 43

before:
Code: [Select]
// Get values
$page_title = $admin->add_slashes($admin->get_post('page_title'));

after:
Code: [Select]
// Get values
$page_link = $admin->add_slashes($admin->get_post('link'));
$page_title = $admin->add_slashes($admin->get_post('page_title'));


approx. line 115
before:
Code: [Select]
// Work-out what the link should be
if($parent == '0') {
        $link = '/'.page_filename($menu_title);
        $filename = WB_PATH.PAGES_DIRECTORY.'/'.page_filename($menu_title).'.php';
} else {
        $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($menu_title);
        $filename = WB_PATH.PAGES_DIRECTORY.'/'.$parent_section.page_filename($menu_title).'.php';
}
if($parent == '0') {
        $link = '/'.page_filename($menu_title);
        $filename = WB_PATH.PAGES_DIRECTORY.'/'.page_filename($menu_title).'.php';
} else {
        $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($menu_title);
        $filename = WB_PATH.PAGES_DIRECTORY.'/'.$parent_section.page_filename($menu_title).'.php';
}


after:
Code: [Select]
// Work-out what the link should be
if($parent == '0') {
        if($page_link != '') {
                $link = '/'.page_filename($page_link);
                $filename = WB_PATH.PAGES_DIRECTORY.'/'.page_filename($page_link).'.php';
        } else {
                $link = '/'.page_filename($menu_title);
                $filename = WB_PATH.PAGES_DIRECTORY.'/'.page_filename($menu_title).'.php';
        }
} else {
        $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 = ''; }
        if($page_link != '') {
                $link = '/'.$parent_section.page_filename($page_link);
                $filename = WB_PATH.PAGES_DIRECTORY.'/'.$parent_section.page_filename($page_link).'.php';
        } else {
                $link = '/'.$parent_section.page_filename($menu_title);
                $filename = WB_PATH.PAGES_DIRECTORY.'/'.$parent_section.page_filename($menu_title).'.php';
        }
}

That is it  :-D
Title: Re: Search Engine Friendly URL, differently to the link name
Post by: ruebenwurzel on November 25, 2006, 08:32:56 AM
Hello,

Why didn't you use the built in options of WB?

You can set the page extension to .html in the advanced options. And in combination with a fixed convert.php you got the result you want. An additional field for Url is not needed, because the pagetitle can be used this.

Changing core files affects that you have to do this changes on every update of WB again.

Matthias
Title: Re: Search Engine Friendly URL, differently to the link name
Post by: danfuh on November 25, 2006, 10:09:58 AM
Hello

The page extension is set in the advanced options.

The displayed extension is the result of the actuel setting.

For some search engines, it is better to put the keyword into the url. But if the menu width is smaller then the keyword, it would be better to have the possibility to change the url, without changing the menulink.
In this case, an additional field for url is needed.

Daniel

Title: Re: Search Engine Friendly URL, differently to the link name
Post by: ruebenwurzel on November 25, 2006, 10:36:12 AM
Hello,

as i understood you the URL is always generated from the menulink and you wanna have a userdefined url and for this you added the new field.

I think it would be better only to have an option where you can decide if the url is generated from menulink or the pagetitle. This way you can use the pagetitle for your keywords and we can make this option downwords kompatible to older WB vesions. Maybe default option is to use the menulink as before and have only an option (per page) where you can activate pagetitle for url generation. What do you think about this?

Matthias
Title: Re: Search Engine Friendly URL, differently to the link name
Post by: danfuh on November 25, 2006, 01:38:50 PM
That is a great idea, but then, pleas without the page-title prefix in the url

example:
pagetitles (meta tag):
My Site - Home of my Site
My Site - Contact us via Mail or Phone
My Site - View our latest News

Menu Links:
Home
Contact
News

URLs:
home-of-my-site.php
contact-us-via-mail-or-phone.php
view-our-latest-news.php

So, that every url/filename is without "My Site"

Where do you want to crate a Switcher, where you can select between URL/Filename creation by Menuname or Title Tag.
Global in the options or for every page?

Daniel

p.s. what do you think about a modul with additional funktiuons link mine above?.
In function, linke the page cloner modul.
Title: Re: Search Engine Friendly URL, differently to the link name
Post by: ruebenwurzel on November 25, 2006, 02:54:50 PM
Hello

Quote
example:
So, that every url/filename is without "My Site"

pagetitles (meta tag):
My Site - Home of my Site
My Site - Contact us via Mail or Phone
My Site - View our latest News

Thats very easy, only call the page Title in the meta tags with

Code: [Select]
<?php page_title(&#39;&#39;,&#39;[PAGE_TITLE]&#39;); ?>
Gives the following result:
Home of my Site
Contact us via Mail or Phone
View our latest News

without the My Site at the beginning and without changing core code files.

And for the switching part i think we only have to change the filename generation to support additional the pagetitle and only add at page settings a option box at the page title and if this is activated the filename is generated from the pagetitle and not from the menülink. Only ideas, will ask the developpers if it is possible.

Matthias
Title: Re: Search Engine Friendly URL, differently to the link name
Post by: amadeus on April 14, 2007, 02:16:50 PM
Hi there, I´m a reader of this forum since some month, and got a lot of help until now - many many thanks to this great community!

Quote
think it would be better only to have an option where you can decide if the url is generated from menulink or the pagetitle. This way you can use the pagetitle for your keywords and we can make this option downwords kompatible to older WB vesions. Maybe default option is to use the menulink as before and have only an option (per page) where you can activate pagetitle for url generation. What do you think about this?

I would also like this feature very much, is there a solution for now, which I can do by myself? I´m not a hardcore php coder but get used to more and more  :wink:
Title: Re: Search Engine Friendly URL, differently to the link name
Post by: Frediwan on April 23, 2008, 04:00:41 PM
hello ,

are these changes of danfuh possible with existing pages?

gruß
frediwan
Title: Re: Search Engine Friendly URL, differently to the link name
Post by: ruebenwurzel on April 23, 2008, 04:23:26 PM
Hello,

this changes are based on an older version of WB. So they are not compatible to the upcoming WB 2.7.

Matthias
Title: Re: Search Engine Friendly URL, differently to the link name
Post by: testdriver2 on December 17, 2008, 10:35:58 PM
I am just experimenting a little bit to get my WebsiteBaker optimized for seo. I have just found another site in this forum dealing with this issue for Version 2.7: https://forum.WebsiteBaker.org/index.php?topic=10661.0
But also this one does not answer my current problem. I am trying to get rid of the "pages" folder. It only works on some servers but not on all. Does anybody have code that works on all servers?
Title: Re: Search Engine Friendly URL, differently to the link name
Post by: kweitzel on December 19, 2008, 07:37:45 PM
The Trick is you have to change the "pages folder" BEFORE you add any page ...

cheers

Klaus