Lowercase Object SEO-URL

In diesem Forum können Wünsche für die Weiterentwicklung von webEdition diskutiert werden.
Gerade bei umfangreichen Änderungen ist es sinnvoll, diese vor einem Eintrag in die Bugbase zu diskutieren. Das Ergebnis kann dann mit Verweis auf den Forumseintrag in die Bugbase eingetragen werden.
Forumsregeln
Bitte achtet hier besonders darauf, nicht abzuschweifen.
Wir werden hier verstärkt moderieren und ggf. Dinge in andere Foren (Smalltalk etc.) auslagern.
Michael_S
Senior Member
Beiträge: 160
Registriert: Mi 4. Feb 2004, 02:39
Wohnort: London / UK
Kontaktdaten:

Lowercase Object SEO-URL

Beitragvon Michael_S » Fr 6. Jun 2014, 17:39

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.
Production Area
London, UK
http://productionarea.com

Benutzeravatar
blickfang
webEdition Partner
webEdition Partner
Beiträge: 812
Registriert: Mo 15. Dez 2003, 16:00
Kontaktdaten:

Re: Lowercase Object SEO-URL

Beitragvon blickfang » Fr 13. Jun 2014, 16:35

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.

Michael_S
Senior Member
Beiträge: 160
Registriert: Mi 4. Feb 2004, 02:39
Wohnort: London / UK
Kontaktdaten:

Re: Lowercase Object SEO-URL

Beitragvon Michael_S » Do 7. Aug 2014, 00:00

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.
Production Area
London, UK
http://productionarea.com

Michael_S
Senior Member
Beiträge: 160
Registriert: Mi 4. Feb 2004, 02:39
Wohnort: London / UK
Kontaktdaten:

Re: Lowercase Object SEO-URL

Beitragvon Michael_S » Do 7. Aug 2014, 00:29

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.
Production Area
London, UK
http://productionarea.com

Benutzeravatar
blickfang
webEdition Partner
webEdition Partner
Beiträge: 812
Registriert: Mo 15. Dez 2003, 16:00
Kontaktdaten:

Re: Lowercase Object SEO-URL

Beitragvon blickfang » Do 7. Aug 2014, 08:57

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:

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;
	}
}
Bye
Timo
webEdition Partner - https://www.blickfang-media.com
Ehemals im Vorstand des webEdition e.V.

Michael_S
Senior Member
Beiträge: 160
Registriert: Mi 4. Feb 2004, 02:39
Wohnort: London / UK
Kontaktdaten:

Re: Lowercase Object SEO-URL

Beitragvon Michael_S » Do 7. Aug 2014, 21:07

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.
Production Area
London, UK
http://productionarea.com

Benutzeravatar
blickfang
webEdition Partner
webEdition Partner
Beiträge: 812
Registriert: Mo 15. Dez 2003, 16:00
Kontaktdaten:

Re: Lowercase Object SEO-URL

Beitragvon blickfang » Fr 8. Aug 2014, 12:31

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.

Michael_S
Senior Member
Beiträge: 160
Registriert: Mi 4. Feb 2004, 02:39
Wohnort: London / UK
Kontaktdaten:

Re: Lowercase Object SEO-URL

Beitragvon Michael_S » Fr 8. Aug 2014, 13:15

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.
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 ;-)
Michael.
Production Area
London, UK
http://productionarea.com

Benutzeravatar
blickfang
webEdition Partner
webEdition Partner
Beiträge: 812
Registriert: Mo 15. Dez 2003, 16:00
Kontaktdaten:

Re: Lowercase Object SEO-URL

Beitragvon blickfang » Mo 11. Aug 2014, 21:17

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.
webEdition Partner - https://www.blickfang-media.com
Ehemals im Vorstand des webEdition e.V.

Michael_S
Senior Member
Beiträge: 160
Registriert: Mi 4. Feb 2004, 02:39
Wohnort: London / UK
Kontaktdaten:

Re: Lowercase Object SEO-URL

Beitragvon Michael_S » Di 12. Aug 2014, 00:51

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.
Production Area
London, UK
http://productionarea.com

Michael_S
Senior Member
Beiträge: 160
Registriert: Mi 4. Feb 2004, 02:39
Wohnort: London / UK
Kontaktdaten:

Re: Lowercase Object SEO-URL

Beitragvon Michael_S » Di 12. Aug 2014, 01:00

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);
Production Area
London, UK
http://productionarea.com

Michael_S
Senior Member
Beiträge: 160
Registriert: Mi 4. Feb 2004, 02:39
Wohnort: London / UK
Kontaktdaten:

Re: Lowercase Object SEO-URL

Beitragvon Michael_S » Mo 18. Aug 2014, 15:10

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.
Production Area
London, UK
http://productionarea.com

AndreasWitt

Re: Lowercase Object SEO-URL

Beitragvon AndreasWitt » Do 22. Jan 2015, 11:16

... 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

Michael_S
Senior Member
Beiträge: 160
Registriert: Mi 4. Feb 2004, 02:39
Wohnort: London / UK
Kontaktdaten:

Re: Lowercase Object SEO-URL

Beitragvon Michael_S » Do 22. Jan 2015, 13:19

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
Hi Andreas,

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.
Production Area
London, UK
http://productionarea.com

AndreasWitt

Re: Lowercase Object SEO-URL

Beitragvon AndreasWitt » So 10. Mai 2015, 10:37

... just for your information. In webEdition 6.5 is a new option to make SEO-URLs always in lowercase.


Zurück zu „webEdition Feature Requests“

Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 6 Gäste