[Skip to main content](#vessel-content)

#   Auto-generate alias on content translation

##

- **[braverman](/forum/user/30455-braverman "View braverman's Profile")**
- [![braverman's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/30455-braverman "View braverman's Profile") Topic Author
- [ Offline](/forum/user/30455-braverman)

Less More

- Posts: 25
- Thank you received: 2
-
-

5 years 1 month ago [\#335340](#335340) by [braverman](/forum/user/30455-braverman "View braverman's Profile")  *[Auto-generate alias on content translation](/forum/32-content-creation/903129-auto-generate-alias-on-content-translation#335340 "-- HikaShop version -- : 4.4.3 -- Joomla version -- : 3.9.28 -- PHP version -- : 7.4.22  Hi,  my client translates hundreds of categories/products/etc. into 4 languages using the Falang extension. All works fine but I am trying to improve it a little. When saving translation from edit page I would like to autogenerate alias according to the name field (using stringURLSafe function). I don't like to hack core files so the ideal solution would be either if you implement this function (should be few lines in translation helper in function handleTranslations and one toggle switch in configuration) or more universally to trigger plugin event before and/or after translation saving.  Does it sound meaningful?  Thanks, Jan")* was created by *[braverman](/forum/user/30455-braverman "View braverman's Profile")*

-- HikaShop version -- : 4.4.3
-- Joomla version -- : 3.9.28
-- PHP version -- : 7.4.22

Hi,

my client translates hundreds of categories/products/etc. into 4 languages using the Falang extension. All works fine but I am trying to improve it a little. When saving translation from edit page I would like to autogenerate alias according to the name field (using stringURLSafe function). I don't like to hack core files so the ideal solution would be either if you implement this function (should be few lines in translation helper in function handleTranslations and one toggle switch in configuration) or more universally to trigger plugin event before and/or after translation saving.

Does it sound meaningful?

Thanks, Jan

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMyLWNvbnRlbnQtY3JlYXRpb24vOTAzMTI5LWF1dG8tZ2VuZXJhdGUtYWxpYXMtb24tY29udGVudC10cmFuc2xhdGlvbj90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86293
- Thank you received: 14271
-
-

5 years 1 month ago -  5 years 1 month ago [\#335342](#335342) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Auto-generate alias on content translation](/forum/32-content-creation/903129-auto-generate-alias-on-content-translation#335342 "-- HikaShop version -- : 4.4.3 -- Joomla version -- : 3.9.28 -- PHP version -- : 7.4.22  Hi,  my client translates hundreds of categories/products/etc. into 4 languages using the Falang extension. All works fine but I am trying to improve it a little. When saving translation from edit page I would like to autogenerate alias according to the name field (using stringURLSafe function). I don't like to hack core files so the ideal solution would be either if you implement this function (should be few lines in translation helper in function handleTranslations and one toggle switch in configuration) or more universally to trigger plugin event before and/or after translation saving.  Does it sound meaningful?  Thanks, Jan")*

Hi,

The handleTranslations is not really adapted to have before/after events.
And you can already use the onAfterProductUpdate and onAfterCategoryUpdate events to set the alias in the translations if empty.
And it's a bit more than a few lines to add code to handle that. It's more like 40 lines to do it properly.
But yes, it's a good idea to generate the alias automatically for the translation when the "alias auto fill" setting of the HikaShop configuration is activated. We'll look at adding that, thanks for your feedback.

Last edit: 5 years 1 month ago by [nicolas](/forum/user/63-nicolas "View nicolas's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMyLWNvbnRlbnQtY3JlYXRpb24vOTAzMTI5LWF1dG8tZ2VuZXJhdGUtYWxpYXMtb24tY29udGVudC10cmFuc2xhdGlvbj90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[braverman](/forum/user/30455-braverman "View braverman's Profile")**
- [![braverman's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/30455-braverman "View braverman's Profile") Topic Author
- [ Offline](/forum/user/30455-braverman)

Less More

- Posts: 25
- Thank you received: 2
-
-

5 years 1 month ago [\#335347](#335347) by [braverman](/forum/user/30455-braverman "View braverman's Profile")  Replied by *[braverman](/forum/user/30455-braverman "View braverman's Profile")* on topic *[Auto-generate alias on content translation](/forum/32-content-creation/903129-auto-generate-alias-on-content-translation#335347 "-- HikaShop version -- : 4.4.3 -- Joomla version -- : 3.9.28 -- PHP version -- : 7.4.22  Hi,  my client translates hundreds of categories/products/etc. into 4 languages using the Falang extension. All works fine but I am trying to improve it a little. When saving translation from edit page I would like to autogenerate alias according to the name field (using stringURLSafe function). I don't like to hack core files so the ideal solution would be either if you implement this function (should be few lines in translation helper in function handleTranslations and one toggle switch in configuration) or more universally to trigger plugin event before and/or after translation saving.  Does it sound meaningful?  Thanks, Jan")*

Thanks! ![:-)](/media/kunena/emoticons/9.png ":-)")

I thought that translation editing uses controller function save_translation that does not update product/category and so does not trigger onAfterProductUpdate or onAfterCategoryUpdate. But maybe I am wrong, did not test it.

Jan

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMyLWNvbnRlbnQtY3JlYXRpb24vOTAzMTI5LWF1dG8tZ2VuZXJhdGUtYWxpYXMtb24tY29udGVudC10cmFuc2xhdGlvbj90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86293
- Thank you received: 14271
-
-

5 years 1 month ago [\#335348](#335348) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Auto-generate alias on content translation](/forum/32-content-creation/903129-auto-generate-alias-on-content-translation#335348 "-- HikaShop version -- : 4.4.3 -- Joomla version -- : 3.9.28 -- PHP version -- : 7.4.22  Hi,  my client translates hundreds of categories/products/etc. into 4 languages using the Falang extension. All works fine but I am trying to improve it a little. When saving translation from edit page I would like to autogenerate alias according to the name field (using stringURLSafe function). I don't like to hack core files so the ideal solution would be either if you implement this function (should be few lines in translation helper in function handleTranslations and one toggle switch in configuration) or more universally to trigger plugin event before and/or after translation saving.  Does it sound meaningful?  Thanks, Jan")*

Hi,

That's my bad. You're correct. Still, we'll look at adding that. It will be better that way as events as not really appropriate there.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMyLWNvbnRlbnQtY3JlYXRpb24vOTAzMTI5LWF1dG8tZ2VuZXJhdGUtYWxpYXMtb24tY29udGVudC10cmFuc2xhdGlvbj90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[braverman](/forum/user/30455-braverman "View braverman's Profile")**
- [![braverman's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/30455-braverman "View braverman's Profile") Topic Author
- [ Offline](/forum/user/30455-braverman)

Less More

- Posts: 25
- Thank you received: 2
-
-

4 years 6 months ago [\#340864](#340864) by [braverman](/forum/user/30455-braverman "View braverman's Profile")  Replied by *[braverman](/forum/user/30455-braverman "View braverman's Profile")* on topic *[Auto-generate alias on content translation](/forum/32-content-creation/903129-auto-generate-alias-on-content-translation#340864 "-- HikaShop version -- : 4.4.3 -- Joomla version -- : 3.9.28 -- PHP version -- : 7.4.22  Hi,  my client translates hundreds of categories/products/etc. into 4 languages using the Falang extension. All works fine but I am trying to improve it a little. When saving translation from edit page I would like to autogenerate alias according to the name field (using stringURLSafe function). I don't like to hack core files so the ideal solution would be either if you implement this function (should be few lines in translation helper in function handleTranslations and one toggle switch in configuration) or more universally to trigger plugin event before and/or after translation saving.  Does it sound meaningful?  Thanks, Jan")*

Hi,
I returned to this topic after some time and found that it is half way. I found changes in handleTranslations method but if I see correctly these changes are never executed because the variable $auto_fill_prefix is never true. Am I correct?

Thanks, Jan

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMyLWNvbnRlbnQtY3JlYXRpb24vOTAzMTI5LWF1dG8tZ2VuZXJhdGUtYWxpYXMtb24tY29udGVudC10cmFuc2xhdGlvbj90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86293
- Thank you received: 14271
-
-

4 years 6 months ago [\#340866](#340866) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Auto-generate alias on content translation](/forum/32-content-creation/903129-auto-generate-alias-on-content-translation#340866 "-- HikaShop version -- : 4.4.3 -- Joomla version -- : 3.9.28 -- PHP version -- : 7.4.22  Hi,  my client translates hundreds of categories/products/etc. into 4 languages using the Falang extension. All works fine but I am trying to improve it a little. When saving translation from edit page I would like to autogenerate alias according to the name field (using stringURLSafe function). I don't like to hack core files so the ideal solution would be either if you implement this function (should be few lines in translation helper in function handleTranslations and one toggle switch in configuration) or more universally to trigger plugin event before and/or after translation saving.  Does it sound meaningful?  Thanks, Jan")*

Hi,

That's a good point. I think I forgot to change the code calling handleTranslations in the product controller.
I'll change the line for the next version (4.5.2) :
$translationHelper-&gt;handleTranslations('product',$element-&gt;product_id,$element);
to:
$translationHelper-&gt;handleTranslations('product',$element-&gt;product_id,$element, 'hikashop_', null, true);
in administrator/components/com_hikashop/controllers/product.php and that should do it.

The following user(s) said Thank You: [braverman](/forum/user/30455-braverman "View braverman's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMyLWNvbnRlbnQtY3JlYXRpb24vOTAzMTI5LWF1dG8tZ2VuZXJhdGUtYWxpYXMtb24tY29udGVudC10cmFuc2xhdGlvbj90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[braverman](/forum/user/30455-braverman "View braverman's Profile")**
- [![braverman's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/30455-braverman "View braverman's Profile") Topic Author
- [ Offline](/forum/user/30455-braverman)

Less More

- Posts: 25
- Thank you received: 2
-
-

4 years 6 months ago [\#340881](#340881) by [braverman](/forum/user/30455-braverman "View braverman's Profile")  Replied by *[braverman](/forum/user/30455-braverman "View braverman's Profile")* on topic *[Auto-generate alias on content translation](/forum/32-content-creation/903129-auto-generate-alias-on-content-translation#340881 "-- HikaShop version -- : 4.4.3 -- Joomla version -- : 3.9.28 -- PHP version -- : 7.4.22  Hi,  my client translates hundreds of categories/products/etc. into 4 languages using the Falang extension. All works fine but I am trying to improve it a little. When saving translation from edit page I would like to autogenerate alias according to the name field (using stringURLSafe function). I don't like to hack core files so the ideal solution would be either if you implement this function (should be few lines in translation helper in function handleTranslations and one toggle switch in configuration) or more universally to trigger plugin event before and/or after translation saving.  Does it sound meaningful?  Thanks, Jan")*

Thanks.

I tested it (patched it according to your post) and found some other errors in translation.php:

On line 327 instead: Code:

if($config-&gt;get('alias_auto_fill', 1) &amp;&amp; $auto_fill_prefix &amp;&amp; $field == $name_field &amp;&amp; !empty($trans) &amp;&amp; empty($transArray[$alias_field])) {

changed to: Code:

if($config-&gt;get('alias_auto_fill', 1) &amp;&amp; $auto_fill_prefix &amp;&amp; $field == $name_field &amp;&amp; !empty($trans) &amp;&amp; empty($transArray[$alias_field][$lg])) {

and line 332 Code:

$emptyObject-&gt;$name_field = $trans;

to Code:

$emptyObject-&gt;$name_field = $value;

Now it works.

Jan

The following user(s) said Thank You: [nicolas](/forum/user/63-nicolas "View nicolas's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMyLWNvbnRlbnQtY3JlYXRpb24vOTAzMTI5LWF1dG8tZ2VuZXJhdGUtYWxpYXMtb24tY29udGVudC10cmFuc2xhdGlvbj90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86293
- Thank you received: 14271
-
-

4 years 6 months ago [\#340882](#340882) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Auto-generate alias on content translation](/forum/32-content-creation/903129-auto-generate-alias-on-content-translation#340882 "-- HikaShop version -- : 4.4.3 -- Joomla version -- : 3.9.28 -- PHP version -- : 7.4.22  Hi,  my client translates hundreds of categories/products/etc. into 4 languages using the Falang extension. All works fine but I am trying to improve it a little. When saving translation from edit page I would like to autogenerate alias according to the name field (using stringURLSafe function). I don't like to hack core files so the ideal solution would be either if you implement this function (should be few lines in translation helper in function handleTranslations and one toggle switch in configuration) or more universally to trigger plugin event before and/or after translation saving.  Does it sound meaningful?  Thanks, Jan")*

Hi,

Thank you for your feedback. We'll add these modifications for the 4.5.2

The following user(s) said Thank You: [braverman](/forum/user/30455-braverman "View braverman's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMyLWNvbnRlbnQtY3JlYXRpb24vOTAzMTI5LWF1dG8tZ2VuZXJhdGUtYWxpYXMtb24tY29udGVudC10cmFuc2xhdGlvbj90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop- Install &amp; Update- Product &amp; Category Display- Content Creation- Sales and Orders- - Orders management- - Reports &amp; Statistics- Customers- Checkout- Payment Methods- Shipping Methods- Import &amp; Export (CSV, XLS…)- Specific Features- - Affilation- - Taxes- - Wishlist- - Vote- - Carousel &amp; Slider- - Mass Actions- - Filters &amp; Search- - Discount &amp; Coupon- - Feature Request- Integrations- Showcase- General Talk about HikaShop- Development- - HikaShop 3.0 Beta- Translation- Commercial Jobs HikaShop Components- HikaMarket- - Market: Feature requests- - Market: How to?- - Market: Bug Report- HikaSerial- - General talk about HikaSerial- - Serial: Bug Report- - Serial: How to?- - Support en Français de HikaSerial (French Support)- - HikaSubscription- HikaAuction- - Auction: Feature requests- - Auction: How to?- - Auction: Bug report Hikashop around the world- Support en Français (French Support)- Russian- - FAQ. Курс выживания с Hikashop. Частые вопросы и о- - Расширения Hikashop- - Наши сайты на Hikashop- 日本語版サポート(Japanese Support)- Thai- German Archives- Bug Report- How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.125 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)

[](#top)
