*

Alex_PY

  • ***
  • 59 posts
Blog plugin incompatibility with language code into base URL
« on: February 12, 2023, 12:37:19 AM »
Good afternoon.

Please add to the plugin development plan: compatibility with the new language code into base URL engine function.

At the moment - if the site is multilingual, and we enable this beta option (domain.com/xx/) - the plugin generates links incorrectly and stops showing those entries that are made to the blog.

Examples of incorrectly generated links (after including domain.com/xx/)
https://mihogar.com.py/ru/blog/article/kak-za-3-dnya-podat-dokumenty-na-vn-zh-paragvaya-b30
https://mihogar.com.py/ru/blog/article/gde-delat-privivku-zheltoj-lihoradki-dlya-paragvaya-b17

Regards, Alex.

*

MB Themes

Re: Blog plugin incompatibility with language code into base URL
« Reply #1 on: February 13, 2023, 09:29:04 AM »
This is sample code to generate article link:
Code: [Select]
    <a class="blg-title" href="<?php echo osc_route_url('blg-post', array('blogSlug' => osc_sanitizeString(blg_get_slug($b'article')), 'blogId' => $b['pk_i_id'])); ?>">

So ID does not matter (basically text is also irrelevant to have link functional).
Plugin will use this to get slug into url:
Code: [Select]
blg_get_slug($b, 'article')
This is piece of slug function:
Code: [Select]
  if(isset($blog['s_slug']) && trim($blog['s_slug']) <> '') {
    $text = $blog['s_slug'];
  } else if (blg_get_title($blog) <> '') {
    $text = blg_get_title($blog);
  } else {
    $text = __('post', 'blog');
  }

Means if you've defined slug in article, this one is alway used, otherwise is generated from title.
This is piece of title function:
Code: [Select]
  if(isset($blog['locales'])) {
    if(blg_field('title', $blog['locales']) <> '') {
      return blg_field('title', $blog['locales']);
    }
  }

  if(isset($blog['s_title']) && $blog['s_title'] <> '') {
    return $blog['s_title'];
  }

It's checking in locales.
It use getBlogLocales from model to get locales.

So, locales are added in form ['locales']['en_US'], ['locales']['de_DE'], ... etc.
blg_field function is build to find most suitable locale.
If exists, it returns locale of osc_current_user_locale(), otherwise site default locale, otherwise search for first non-empty.

So basically do not see any problem here.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots