*

Maya

  • *
  • 4 posts
Search URL
« on: November 27, 2024, 10:28:07 AM »
localhost/hesla-c4270118 change to  localhost/hesla how to do ?

*

MB Themes

Re: Search URL
« Reply #1 on: November 29, 2024, 03:37:31 PM »
You cannot.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

Maya

  • *
  • 4 posts
Re: Search URL
« Reply #2 on: November 29, 2024, 10:30:18 PM »
You cannot.
Why?

I'm  modify core, now link expected  localhost/hesla

404 error

can you please suggest a solution



 if(isset($params['sCity'])) {
        if(osc_list_city_id()==$params['sCity']) {
          $url .= osc_sanitizeString(osc_list_city_slug()) . '-c' . osc_list_city_id();

        } else {
          if(is_numeric($params['sCity'])) {
            $city = City::newInstance()->findByPrimaryKey($params['sCity']);
          } else {
            $city = City::newInstance()->findBySlug($params['sCity']);

            // if(!isset($city['pk_i_id'])) {  // update 440
            //   $city = City::newInstance()->findByName($params['sCity']);
            // }
          }

          if(isset($city['s_slug'])) {
            $url .= osc_sanitizeString($city['s_slug'] != '' ? $city['s_slug'] : $city['s_name']);
          } else {
            // Search by a city which does not exists (by form)
            // TODO CHANGE TO NEW ROUTES!!
            // return $url . 'index.php?page=search&sCity=' . urlencode($params['sCity']);

            // Lang code in base URL cannot be used
            // return osc_base_url(false, false) . 'index.php?page=search&sCity=' . urlencode($params['sCity']);
          }
        }
      }

*

Wiz

  • ****
  • 153 posts
Re: Search URL
« Reply #3 on: December 02, 2024, 06:06:38 AM »
Doable but not recommended unless you know what you're doing and have decided to maintain a separate codebase as you'll be modifying several files and changing search logic.

Hint: start by searching for all instances of '-c' which will give you an idea of the effort involved.

*

Maya

  • *
  • 4 posts
Re: Search URL
« Reply #4 on: December 02, 2024, 07:38:20 AM »
Only "-c" in 2 files

1. oc-includes\osclass\helpers\hSearch.php

if(isset($params['sCity'])) {
        if(osc_list_city_id()==$params['sCity']) {
          $url .= osc_sanitizeString(osc_list_city_slug()) . '-c' . osc_list_city_id();

        } else {
          if(is_numeric($params['sCity'])) {
            $city = City::newInstance()->findByPrimaryKey($params['sCity']);
          } else {
            $city = City::newInstance()->findBySlug($params['sCity']);

            if(!isset($city['pk_i_id'])) {  // update 440
              $city = City::newInstance()->findByName($params['sCity']);
            }
          }

          if(isset($city['s_slug'])) {
            $url .= osc_sanitizeString($city['s_slug'] != '' ? $city['s_slug'] : $city['s_name']) . '-c' . $city['pk_i_id'];
          } else {
            // Search by a city which does not exists (by form)
            // TODO CHANGE TO NEW ROUTES!!
            // return $url . 'index.php?page=search&sCity=' . urlencode($params['sCity']);

            // Lang code in base URL cannot be used
            return osc_base_url(false, false) . 'index.php?page=search&sCity=' . urlencode($params['sCity']);
          }
        }
      }

2. oc-includes\osclass\controller\search.php

 // get only the last segment
        $search_uri = preg_replace('|.*?/|', '', $search_uri);
        if(preg_match('|-r([0-9]+)$|', $search_uri, $r)) {
          $region = Region::newInstance()->findByPrimaryKey($r[1]);
          if(!$region) {
            $this->do404();
          }

          Params::setParam('sRegion', $region['pk_i_id']);

          if(osc_subdomain_type() != 'category') {
            Params::unsetParam('sCategory');
          }

          if(preg_match('|(.*?)_.*?-r[0-9]+|', $search_uri, $match)) {
            Params::setParam('sCategory', $match[1]);
          }

        } else if(preg_match('|-c([0-9]+)$|', $search_uri, $c)) {
          $city = City::newInstance()->findByPrimaryKey($c[1]);
          if(!$city) {
            $this->do404();
          }

          Params::setParam('sCity', $city['pk_i_id']);

          if(osc_subdomain_type() != 'category') {
            Params::unsetParam('sCategory');
          }

          if(preg_match('|(.*?)_.*?-c[0-9]+|', $search_uri, $match)) {
            Params::setParam('sCategory', $match[1]);
          }

        }


I'm removed "-c" URL get expected but 404 Error

*

MB Themes

Re: Search URL
« Reply #5 on: December 02, 2024, 10:07:54 AM »
because now your URL is considered as "category url" because it match category pattern.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

Maya

  • *
  • 4 posts
Re: Search URL
« Reply #6 on: December 03, 2024, 11:59:37 AM »
because now your URL is considered as "category url" because it match category pattern.

Any Solution ??

*

MB Themes

Re: Search URL
« Reply #7 on: December 03, 2024, 01:39:51 PM »
We plan to enhance search patterns and urls in future in way like this:
/some/text - category url
/a/sometext - city url
/b/sometext - region url
/c/sometext - country url
/d/some/text - region + city url
/e/some/cool/text - category + region + city

etc.
Means there is one letter (a,b,c...) that is not anyhow bad for SEO and you still able to create various patterns
You might test something like this.

Not simple....
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots