statamic / v2-hub

Statamic 2 - Feature Requests and Bug Reports
https://statamic.com
95 stars 5 forks source link

Entry pages locale data error #2404

Open emre-koc opened 5 years ago

emre-koc commented 5 years ago

Describe the bug A clear and concise description of what the bug is.

To Reproduce Steps to reproduce the behavior:

  1. Create a collection
  2. Create entries in collection
  3. Create two locales in statamic lets say default is / and we have /ca/ locale

Entry pages work in default configuration like /store/itemname but does not work in /ca/store/itemname

Expected behavior A clear and concise description of what you expected to happen. /store/itemname need to open default locale entry page /ca/store/itemname need to open CA locale entry page

Solution I debugged the source and found the problem on StatamicController Line:299-313. I fixed it with this code. Previously you wrote if ($requested_uri === $content->uri()) but this $content->uri() returns with locale info. $requested_uri does not have this locale so they dont match.

` if ($content = Content::whereUri($uri)) { $content_uri = $content->uri(); // Place the content in the locale we want. $content = $content->in(site_locale());

        // If the requested URI exists, but also has a localized version, the
        // default URI should not be accessible. For example, if /team has
        // been localized to /equipe, visiting /about should throw a 404.
        if ($requested_uri === $content_uri) {
            $content->supplementTaxonomies();
            return $content;
        }
    }`

Screenshots If applicable, add screenshots to help explain your problem.

Environment details (please complete the following information):

Additional context Add any other context about the problem here.

jasonvarga commented 5 years ago

Seems to work OK here. Sorry about the delay. If you still have this issue can you post your collection yaml files and entry markdown files?