Lowercase Object SEO-URL
Forumsregeln
Bitte achtet hier besonders darauf, nicht abzuschweifen.
Wir werden hier verstärkt moderieren und ggf. Dinge in andere Foren (Smalltalk etc.) auslagern.
Bitte achtet hier besonders darauf, nicht abzuschweifen.
Wir werden hier verstärkt moderieren und ggf. Dinge in andere Foren (Smalltalk etc.) auslagern.
-
- Senior Member
- Beiträge: 160
- Registriert: Mi 4. Feb 2004, 02:39
- Wohnort: London / UK
- Kontaktdaten:
Lowercase Object SEO-URL
Apologies if this has already been discussed.
For the sake of a tidy and short URL I often create a field in a Object Class for a permalink and use this as the SEO-URL field and enter a lowercase string which is optimised for the content. However if the editor is not meticulous I end up with a mixture of upper and lower case characters which makes me unhappy ;-)
Has this been suggested and would it be possible, possibly as a option in the SEO Links preferences.
Michael.
For the sake of a tidy and short URL I often create a field in a Object Class for a permalink and use this as the SEO-URL field and enter a lowercase string which is optimised for the content. However if the editor is not meticulous I end up with a mixture of upper and lower case characters which makes me unhappy ;-)
Has this been suggested and would it be possible, possibly as a option in the SEO Links preferences.
Michael.
Re: Lowercase Object SEO-URL
we shift this problem by using the prepublish hook. we create a textinput in the webEdtion Class that is only visible for Admins. In the prepublish hook we define the rule, how to build the seo-url (e.g. sometimes we join different fields) and set spaces to minus an characters to lowercase. In case you have doublicate fieldvalues, you have to take care of add a numeric counter or any else to build a unique url. otherwise the user can not save the object and does not know why
webEdition Partner - https://www.blickfang-media.com
Ehemals im Vorstand des webEdition e.V.
Ehemals im Vorstand des webEdition e.V.
-
- Senior Member
- Beiträge: 160
- Registriert: Mi 4. Feb 2004, 02:39
- Wohnort: London / UK
- Kontaktdaten:
Re: Lowercase Object SEO-URL
Hi biwaMedia,
This is interesting and it sounds like it solves the lowercase URL issue and may also help me with a problem I'm having at the moment.
Is it possible to use the prepublish hook to construct a SEO URL using a field from a linked Object, for example I have the following classes and would like to construct the SEO URL below:
Class: Artist
Field: Artist_Name
Class: Work
Field: Work_Title
SEO URL: [Artist_Name]/[Work_Title]
Also do I have to give the prepublish hook field a specific name?
Michael.
This is interesting and it sounds like it solves the lowercase URL issue and may also help me with a problem I'm having at the moment.
Is it possible to use the prepublish hook to construct a SEO URL using a field from a linked Object, for example I have the following classes and would like to construct the SEO URL below:
Class: Artist
Field: Artist_Name
Class: Work
Field: Work_Title
SEO URL: [Artist_Name]/[Work_Title]
Also do I have to give the prepublish hook field a specific name?
Michael.
-
- Senior Member
- Beiträge: 160
- Registriert: Mi 4. Feb 2004, 02:39
- Wohnort: London / UK
- Kontaktdaten:
Re: Lowercase Object SEO-URL
Hi biwaMedia,
I've found the sample_hooks and can see where the custom_hooks should be saved but I'm still unsure how to call the custom_hook from the hidden Object field (only visible for Admins).
Thanks,
Michael.
I've found the sample_hooks and can see where the custom_hooks should be saved but I'm still unsure how to call the custom_hook from the hidden Object field (only visible for Admins).
Thanks,
Michael.
Re: Lowercase Object SEO-URL
Hi Michael,
first of all, the hook managament must be activated in the webEdition Preferences. In the german GUI "Extras => Allgemein => System". Then the hooks in custom_hooks will be executed. The hook is called every time you trigger the specific function (save, publish...) independent from any fields or object classes etc.
To save the seoUrl to the object, yout hook could look something like this:
Bye
Timo
first of all, the hook managament must be activated in the webEdition Preferences. In the german GUI "Extras => Allgemein => System". Then the hooks in custom_hooks will be executed. The hook is called every time you trigger the specific function (save, publish...) independent from any fields or object classes etc.
To save the seoUrl to the object, yout hook could look something like this:
Code: Alles auswählen
function weCustomHook_prePublish($param) {
$hookHandler = $param['hookHandler'];
$object = $param[0];
$type = get_class($object);
switch ($type) {
case 'we_objectFile':
switch ($object->TableID) {
case 10: // the id of the object class in webEdition
$myfield1 = $object->getElement('name_of_the_object_field');
$myfield2 = $object->getElement('name_of_the_object_field');
$seoUrl = $myfield1 . $myfield2; // build your seo url as you want it to look like
$object->setElement('name_of_the_seo_url_admin_object_field', $seoUrl);
break;
case 5: // the id of another object class
// do anything
break;
}
break;
default:
return true;
break;
}
}
Timo
webEdition Partner - https://www.blickfang-media.com
Ehemals im Vorstand des webEdition e.V.
Ehemals im Vorstand des webEdition e.V.
-
- Senior Member
- Beiträge: 160
- Registriert: Mi 4. Feb 2004, 02:39
- Wohnort: London / UK
- Kontaktdaten:
Re: Lowercase Object SEO-URL
Hi Timo,
Thats excellent it works really well and I can see that the hooks could be incredibly useful, wish I looked at this years ago!
One point to add for anyone looking at using hooks for custom SEO URL's or whatever else you might need the data only shows when you refresh the Object or close and open again. Obviously if the object field has restricted access only the admin's or admin group's can see the field which protects the data from being changed, important for permalink's and SEO.
Thanks,
Michael.
Thats excellent it works really well and I can see that the hooks could be incredibly useful, wish I looked at this years ago!
One point to add for anyone looking at using hooks for custom SEO URL's or whatever else you might need the data only shows when you refresh the Object or close and open again. Obviously if the object field has restricted access only the admin's or admin group's can see the field which protects the data from being changed, important for permalink's and SEO.
Thanks,
Michael.
Re: Lowercase Object SEO-URL
you also have to look for producing unique seo-urls (over all objects!). Otherwise the object will not be saved! You can add the object-id or find another way to uniqueness
webEdition Partner - https://www.blickfang-media.com
Ehemals im Vorstand des webEdition e.V.
Ehemals im Vorstand des webEdition e.V.
-
- Senior Member
- Beiträge: 160
- Registriert: Mi 4. Feb 2004, 02:39
- Wohnort: London / UK
- Kontaktdaten:
Re: Lowercase Object SEO-URL
Hi Timo,
I've just tested saving Objects with and without sep-urls and I can save without issues, I currently have 9 classes, 1 with a custom prePublish hook. I'm using webEdition version 6.3.8.0 (SVN-Revision: 6985) official release.
I've just tested saving Objects with and without sep-urls and I can save without issues, I currently have 9 classes, 1 with a custom prePublish hook. I'm using webEdition version 6.3.8.0 (SVN-Revision: 6985) official release.
Michael.biwaMedia hat geschrieben:you also have to look for producing unique seo-urls (over all objects!). Otherwise the object will not be saved! You can add the object-id or find another way to uniqueness
Re: Lowercase Object SEO-URL
Hi Michael,
you can have severalobject classes with different seo url logics . that's no problem. but as I remember the webedition SSEOR URL redirect script, the seo url must be unique. Otherwise webEdition does not know which object to display if there are two or more objects to display with one ulr => domain.com/my-seo-url (obejct 1) => domain.com/my-seo-url (object 2).
There must be thrown an webEdition error if you => setElement('myfield','myvalue') to a seourl field, if this seo-url is already used by another object.
you can have severalobject classes with different seo url logics . that's no problem. but as I remember the webedition SSEOR URL redirect script, the seo url must be unique. Otherwise webEdition does not know which object to display if there are two or more objects to display with one ulr => domain.com/my-seo-url (obejct 1) => domain.com/my-seo-url (object 2).
There must be thrown an webEdition error if you => setElement('myfield','myvalue') to a seourl field, if this seo-url is already used by another object.
webEdition Partner - https://www.blickfang-media.com
Ehemals im Vorstand des webEdition e.V.
Ehemals im Vorstand des webEdition e.V.
-
- Senior Member
- Beiträge: 160
- Registriert: Mi 4. Feb 2004, 02:39
- Wohnort: London / UK
- Kontaktdaten:
Re: Lowercase Object SEO-URL
Hi Timo,
Yes, I've been careful to make sure the seo-url's are unique. I'm moving a site from Expression Engine into webEdition and needed the extra flexibility the prePublish hook's gave me and its working well. Thanks for the help.
Michael.
Yes, I've been careful to make sure the seo-url's are unique. I'm moving a site from Expression Engine into webEdition and needed the extra flexibility the prePublish hook's gave me and its working well. Thanks for the help.
Michael.
-
- Senior Member
- Beiträge: 160
- Registriert: Mi 4. Feb 2004, 02:39
- Wohnort: London / UK
- Kontaktdaten:
Re: Lowercase Object SEO-URL
One note on prePublish hook's for dealing with date fields and timestamps ... PHP 'date' did not work for me but 'gmdate' did.
Code: Alles auswählen
// Class fields
$myDate = $object->getElement('Class_Date_Field');
// Get year from timestamp
$myYear = gmdate('Y', $myDate);
-
- Senior Member
- Beiträge: 160
- Registriert: Mi 4. Feb 2004, 02:39
- Wohnort: London / UK
- Kontaktdaten:
Re: Lowercase Object SEO-URL
Hi Timo,
When working in hooks what do I use to call the Object ID, I've tested WE_ID, OF_ID, etc. but without results.
Michael.
When working in hooks what do I use to call the Object ID, I've tested WE_ID, OF_ID, etc. but without results.
Michael.
Re: Lowercase Object SEO-URL
... you'l don't need an extra field for lowercase SEO-URLs: have a look here: http://blog.webedition.org/2014/07/weti ... klein.html
-
- Senior Member
- Beiträge: 160
- Registriert: Mi 4. Feb 2004, 02:39
- Wohnort: London / UK
- Kontaktdaten:
Re: Lowercase Object SEO-URL
Hi Andreas,AndreasWitt hat geschrieben:... you'l don't need an extra field for lowercase SEO-URLs: have a look here: http://blog.webedition.org/2014/07/weti ... klein.html
Thanks for the link... didn't know the blog existed! I will test the code for the lowercase SEO URL, thanks for the prompt.
Cheers,
Michael.
Re: Lowercase Object SEO-URL
... just for your information. In webEdition 6.5 is a new option to make SEO-URLs always in lowercase.
Wer ist online?
Mitglieder in diesem Forum: 0 Mitglieder und 28 Gäste