This topic contains a post which is marked as Best Answer. Press here if you would like to see it.
*

maxdual

  • **
  • 6 posts
Error when using {ITEM CITY} IN PREMIUM URLS
« on: November 30, 2022, 02:49:52 PM »
Error in semantic url in premium display
I am creating a premium display with the following code.

   <?php osc_get_premiums(4); ?>
<?php if (osc_count_premiums() > 0) { ?>

<?php  while (osc_has_premiums()) { ?>

 <a href="<?php echo osc_premium_url(); ?>"></a>
 <?php } ?>
  <?php } ?>

To Reproduce

Anomaly only plays on premium urls
domain/category/subcategory/{ITEM_CITY}/ads-example_i1

Expected behavior
non-premium url expected behavior

domain/category/subcategory/city/ads-example_i1

My permalink settings
{CATEGORIES}/{ITEM_CITY}/{ITEM_TITLE}_i{ITEM_ID}

Is there something wrong in my approach or is it an osclass bug
« Last Edit: November 30, 2022, 02:52:48 PM by maxdual »

*

MB Themes

Re: Error when using {ITEM CITY} IN PREMIUM URLS
« Reply #1 on: November 30, 2022, 03:56:58 PM »
Ok so for premium items {ITEM_CITY} is not properly translated into city value. Right?
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

maxdual

  • **
  • 6 posts
Re: Error when using {ITEM CITY} IN PREMIUM URLS
« Reply #2 on: November 30, 2022, 04:28:33 PM »

Exactly, if you need more information about my development scenario.

*

MB Themes

Re: Error when using {ITEM CITY} IN PREMIUM URLS
« Reply #3 on: December 01, 2022, 10:32:26 PM »
will try to check soon
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

maxdual

  • **
  • 6 posts
Re: Error when using {ITEM CITY} IN PREMIUM URLS
« Reply #4 on: December 01, 2022, 11:53:37 PM »

I am checking this in the file /oc-includes/osclass/helpers/hDifines.php

function osc_premium_url($locale = '') {
  if ( osc_rewrite_enabled() ) {
    $sanitized_categories = array();
    $cat = Category::newInstance()->hierarchy(osc_premium_category_id());
   
    for ($i = count( $cat); $i > 0; $i--) {
      $sanitized_categories[] = $cat[$i - 1]['s_slug'];
    }
   
    $url = str_replace(
      array('{ITEM_ID}', '{CATEGORIES}'),
      array(osc_premium_id(), implode( '/' , $sanitized_categories)),
      str_replace( '{ITEM_TITLE}', osc_sanitizeString( str_replace( ',', '-', osc_premium_title())), osc_get_preference( 'rewrite_item_url'))
    );

    if($locale!='') {
      $path = osc_base_url() . $locale . '/' . $url;
    } else {
      $path = osc_base_url() . $url;
    }
  } else {
    $path = osc_item_url_ns(osc_premium_id(), $locale);
  }
  return $path;
}

*

MB Themes

Re: Error when using {ITEM CITY} IN PREMIUM URLS
« Reply #5 on: December 02, 2022, 12:25:22 PM »
Not quite sure if it is defined here, but you can try to add before line     if($locale!='') {
following:

Code: [Select]
if(osc_premium_city() <> '') {
  $url = str_replace(('{ITEM_CITY}', osc_premium_city(), $url);
} else {
  $url = str_replace(('/{ITEM_CITY}/', '/', $url);
}
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

maxdual

  • **
  • 6 posts
Re: Error when using {ITEM CITY} IN PREMIUM URLS
« Reply #6 on: December 02, 2022, 05:06:40 PM »

I was trying a similar approach to yours, to rewrite the url
obtaining an optimal result, but not appropriate in the cases of users who want their urls to have a good SEO, due to the use of upper and lower case in the rewriting of the url.

#Parenthesis correction
#functional to test it

 if(osc_premium_city() <> '') {
  $url = str_replace('{ITEM_CITY}', osc_premium_city(), $url);
} else {
  $url = str_replace('/{ITEM_CITY}/', '/', $url);
}

*

MB Themes

Re: Error when using {ITEM CITY} IN PREMIUM URLS
« Reply #7 on: December 02, 2022, 05:15:46 PM »
So does it fix the issue or not?
I am not sure if letter size has any effect on seo.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

maxdual

  • **
  • 6 posts
Re: Error when using {ITEM CITY} IN PREMIUM URLS
« Reply #8 on: December 02, 2022, 05:32:39 PM »

It works well, you just have to test it more to have greater security.
That's what I'll be doing the next few days testing.

I'll tell you about any anomaly you may have.
grateful for your provision.  :)

*

MB Themes

Re: Error when using {ITEM CITY} IN PREMIUM URLS
« Reply #9 on: December 02, 2022, 09:36:44 PM »
Yes, great, I will review code also for other keywords
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

Marked as best answer by frosticek on December 08, 2022, 08:37:10 PM
*

MB Themes

Re: Error when using {ITEM CITY} IN PREMIUM URLS
« Reply #10 on: December 06, 2022, 11:59:25 AM »
@Maxdual
try to replace whole function with just one line:
Code: [Select]
return osc_item_url_from_item(osc_premium(), $locale);
It should fix issue completely.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

maxdual

  • **
  • 6 posts
Re: Error when using {ITEM CITY} IN PREMIUM URLS
« Reply #11 on: December 08, 2022, 08:02:47 PM »
 
I am testing in my environment return osc_item_url_from_item(osc_premium(), $locale); and the problem is completely solved.
obtaining a url without capital letters, commas or accents, very optimal for users looking for a good SEO with their urls.
Excellent the last solution is more complete and better performance is achieved

 :)

*

MB Themes

Re: Error when using {ITEM CITY} IN PREMIUM URLS
« Reply #12 on: December 08, 2022, 08:36:51 PM »
Yes great thanks for confirmation ;)
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots