GithubHelp home page GithubHelp logo

Comments (33)

viraj-khatavkar avatar viraj-khatavkar commented on August 12, 2024

@opheliadesign is it creating same slug if count of slug is not present at end ?

from easy-slug.

opheliadesign avatar opheliadesign commented on August 12, 2024

@viraj-khatavkar correct. So if football-season exists already, EasySlug still uses football-season for the next entry. It only increments if the first one is football-season-1

from easy-slug.

viraj-khatavkar avatar viraj-khatavkar commented on August 12, 2024

okay will look at it and revert in some time

from easy-slug.

opheliadesign avatar opheliadesign commented on August 12, 2024

Thanks!

from easy-slug.

opheliadesign avatar opheliadesign commented on August 12, 2024

I am thinking that this is an issue in the queries within EasySlugRepository.

from easy-slug.

viraj-khatavkar avatar viraj-khatavkar commented on August 12, 2024

got the issue, will resolve it in under an hour

from easy-slug.

viraj-khatavkar avatar viraj-khatavkar commented on August 12, 2024

@opheliadesign Please do composer update once and check. I have resolved it. But, please check and let me know

from easy-slug.

opheliadesign avatar opheliadesign commented on August 12, 2024

@viraj-khatavkar yes, that fixed it! Thanks so much!

from easy-slug.

viraj-khatavkar avatar viraj-khatavkar commented on August 12, 2024

@opheliadesign Sure.. Anytime 👍 I will close this issue then ?

from easy-slug.

viraj-khatavkar avatar viraj-khatavkar commented on August 12, 2024

@opheliadesign Please do composer update once again. There was one syntax issue that I resolved just now

from easy-slug.

opheliadesign avatar opheliadesign commented on August 12, 2024

Yes, you may close this issue - and will do, thanks!

from easy-slug.

opheliadesign avatar opheliadesign commented on August 12, 2024

Greetings! It appears that this is happening in v2.0.4 again.

from easy-slug.

opheliadesign avatar opheliadesign commented on August 12, 2024

Any progress on this? Here is the code that I suspect is causing this:

if ( $count_of_matching_slugs > 0 )
        {
            $temporary_slug = $this->generateSlug( $string . " " . ( $count_of_matching_slugs + 1 ) , $separator );

            $flag = false;

            $i = 2;
            while($flag == false)
            {
                $exact_slugs = $this->_easy_slug_repo->getCountOfExactSlugs($table, $column, $temporary_slug);

                if($exact_slugs > 0)
                {
                    $temporary_slug = $this->generateSlug( $string . " " . ( $count_of_matching_slugs + $i ) , $separator );
                    $i++;
                }
                else
                {
                    $flag = true;
                }
            }
        }
        else {
            $temporary_slug = $temporary_slug . '-1'; // This will always start at -1 rather than just a plain slug
        }

from easy-slug.

viraj-khatavkar avatar viraj-khatavkar commented on August 12, 2024

@opheliadesign can you please post an use case of the issue. I have been using this version in about 13 production applications and I haven't deduced this issue. It would be really helpful with the usecase

from easy-slug.

opheliadesign avatar opheliadesign commented on August 12, 2024

@viraj-khatavkar the use case is generating a unique slug, as outlined on the initial issue report above. The first unique slug, according to the documentation and my preference, should not have a -1 suffix. This is being appended by:

....
} else {
            $temporary_slug = $temporary_slug . '-1'; // This will always start at -1 rather than just a plain slug
        }

To be clear, the code mentioned in this post and my last is from your package.

from easy-slug.

opheliadesign avatar opheliadesign commented on August 12, 2024

@viraj-khatavkar any progress on this?

from easy-slug.

opheliadesign avatar opheliadesign commented on August 12, 2024

@viraj-khatavkar starting a new project and still running into this, a post with the title "Test Post" and this code generates "test-post-1" instead of "test-post"

EasySlug::generateUniqueSlug($request->input('title'), 'posts');

from easy-slug.

viraj-khatavkar avatar viraj-khatavkar commented on August 12, 2024

@opheliadesign any problem in that, I did this to avoid another conflicting issue in case of a string like "abc 1" and 2 times "abc"

from easy-slug.

opheliadesign avatar opheliadesign commented on August 12, 2024

@viraj-khatavkar Most sites, including mine, seem to favor adding -x only if there are multiple posts with that title. Your documentation and previous implementation follow this -

"This function looks for similar slugs in the table/column name specified in parameters. If slugs with similar pattern are found it appends numeric digits at the end of slug as follows :"

your-string
your-string-2
your-string-3
your-string-4

If we could go back to this format, I'd really appreciate it. Thanks for replying so quickly :)

from easy-slug.

viraj-khatavkar avatar viraj-khatavkar commented on August 12, 2024

Okay, give me an hour, I will look into that if I can go back to that :)

Apology for not replying for the last time you raised this, was bit busy in some work and then forgot :( Will look to this ASAP

from easy-slug.

opheliadesign avatar opheliadesign commented on August 12, 2024

Sure, no problem! Really appreciate it. I've been busy since then, too ;)

from easy-slug.

opheliadesign avatar opheliadesign commented on August 12, 2024

Just a thought, maybe a little RegEx magic to see if the title ends in a digit? That way you could prevent the issue that you mentioned but otherwise return the typical slug without an appended number if it's unique.

from easy-slug.

viraj-khatavkar avatar viraj-khatavkar commented on August 12, 2024

Doing that is not an issue. If I check that last digit is a number or not I am stuck in following case :

  1. "abc" -> "abc"
  2. "abc" -> "abc-1"
  3. "abc-1" -> "abc-1" //Now, this is a conflicting case for me

from easy-slug.

opheliadesign avatar opheliadesign commented on August 12, 2024

Hmm yes I see what you're saying. If there isn't already abc-1 in the database, start with abc-1. If it's the second abc-1, go to abc-1-2 and so on. Just a thought, have not looked at your source in a bit.

from easy-slug.

stygiansabyss avatar stygiansabyss commented on August 12, 2024

What about an optional parameter in generateUnique that would allow us to pass in the name column. So it could look for existing entries like it does now, then compare them against the name. If the name has a digit at the end, you would know you still need to append a digit.

from easy-slug.

opheliadesign avatar opheliadesign commented on August 12, 2024

@viraj-khatavkar nag nag nag nag ... sorry, just had to do it ;)

@stygiansabyss great idea, I like it.

from easy-slug.

stygiansabyss avatar stygiansabyss commented on August 12, 2024

Ended up using https://github.com/cviebrock/eloquent-sluggable.
For this package though, you could look at how he is doing it. He has you add a build_from and save_to on the model. Which was the idea I suggested. Knowing the name gives you more control over how to slug.

from easy-slug.

viraj-khatavkar avatar viraj-khatavkar commented on August 12, 2024

@opheliadesign I found a solution, will implement it in a day, if you are still holding on to this package

from easy-slug.

opheliadesign avatar opheliadesign commented on August 12, 2024

Honestly, I've started using the other package mentioned in this thread. However, I like the simplicity of yours. If you can implement a fix I will most likely use it again.

Thanks!

from easy-slug.

raidenz avatar raidenz commented on August 12, 2024

hi i get it bugged me too, i try to solve this here
if i have
title -------------- slug
"abc" it will be "abc-2"
"abc-1" it will be "abc-1-2"

from easy-slug.

viraj-khatavkar avatar viraj-khatavkar commented on August 12, 2024

@raidenz can you send a pull request ?

from easy-slug.

raidenz avatar raidenz commented on August 12, 2024

sure

from easy-slug.

thewhisperinyourears avatar thewhisperinyourears commented on August 12, 2024

works like a charm

from easy-slug.

Related Issues (3)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.