Jump to content
thirty bees forum
  • 0

Problem saving SEO url routes


braffas

Question

Hello

First of all: Thanks for doing this! I really like the code changes in have seen in TB so far :)

There seems to be a problem with saving SEO url routes (nothing is saved in configuration). The default values from the dispatcher class is used when the form is reloaded.

I have upgradede a PS shop (1.6.1.11) to TB (1.0.1).

I have tried with no overrides and only native modules.

Link to comment
Share on other sites

9 answers to this question

Recommended Posts

  • 0

The problem for me was that my changes did not show in the admin section, but they were applied.

The problem seems to be with the method below in AdminMetaController

/**
 * @param string $routeId
 * @param string $title
 *
 * @since 1.0.0
 */
public function addFieldRoute($routeId, $title)
{
    $keywords = array();
    foreach (Dispatcher::getInstance()->default_routes[$routeId]['keywords'] as $keyword => $data) {
        $keywords[] = ((isset($data['param'])) ? '<span class="red">'.$keyword.'*</span>' : $keyword);
    }
    $this->fields_options['routes']['fields']['PS_ROUTE_'.$routeId] = array(
        'title' =>    $title,
        'desc' => sprintf($this->l('Keywords: %s'), implode(', ', $keywords)),
        'validation' => 'isString',
        'type' => 'text', //<----- that needs to be 'textLang'
        'size' => 70,
        'defaultValue' => Dispatcher::getInstance()->default_routes[$routeId]['rule'],
    );
}
Link to comment
Share on other sites

  • 0

Thanks for providing this patch, @braffas. I can confirm this misbehavior.

While this change indeed appears to work, I think it's the wrong solution. This makes rewriting rules language dependent, rules are then stored in table tb_configuration_lang instead of tb_configuration. I don't think setting different rules for distinct languages works.

I'm currently searching for a better solution.

Link to comment
Share on other sites

  • 0

I just looked at my notes. I'm pretty sure the config is still stored in configuration_lang without the patch (AdminMetaController.php ~ 711 - 715), but the default values are shown because 'type' => 'text' are not handled by generateOptions in HelperOptions.php which fills the form. (textLang is handled)

Link to comment
Share on other sites

  • 0

Code snippets I found are a bit contradicting. Default values ignore the language. Installer installs apparently empty fields in configuration. Other code snippets, the one you found, too, handle it as language dependent.

This raises the question whether language dependent rewrite rules can work and if yes, whether they're a wanted feature. Having language dependent rewrite rules easily opens a can of worms, e.g. just switching the language might lead to a 404 page.

Link to comment
Share on other sites

  • 0

I totally agree. It was just a quick fix (I'm only using 1 lang so it worked for me). But you are totally right about the can of worms :)

I think the routes are better stored with no language dependency. It should be a pretty easy fix.

Link to comment
Share on other sites

  • 0

Done: https://github.com/thirtybees/thirtybees/pull/249

A couple of things I learned along the way:

  • Language-aware rewrite rules are a pretty young, 30bz-only feature.
  • They do work, switching languages on a product page changes it's URL as appropriate.
  • Entries in configuration_lang aren't self-sufficient. They're kind of an add-on to an entry in configuration.
  • Installer does indeed create ..._lang entries, my installed DB was too old.
  • @braffas' patch is spot-on. Thank you.
Link to comment
Share on other sites

  • 0

@Traumflug Thx a lot for this fix!

I noticed that the url showed on product editing (tab: SEO) doesn't show the correct path:

0_1496756370248_product_url.JPG

I use: {categories:/}{id}-{rewrite}

So the id is just missing. It's ofc not so important, but just wanted to note...

Edit: Just to make sure... "4" isnt the id. thats part of url rewrite...

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...