rtconner / laravel-tagging

Tag support for Laravel Eloquent models - Taggable Trait
MIT License
882 stars 168 forks source link

Tag first letter capital #151

Closed virumandaliya closed 5 years ago

virumandaliya commented 6 years ago

Tag first letter becomes capital even I enter in small letters.

I want tags save as it is in database. if enter capital than save tag as capital in db. if enter small than save tag as small in db.

Can you please help me out for this?

rtconner commented 6 years ago

There is a config.php file you can adjust this setting

On Sunday, June 17, 2018, virumandaliya notifications@github.com wrote:

Tag first letter becomes capital even I enter in small letters.

I want tags save as it is in database. if enter capital than save tag as capital in db. if enter small than save tag as small in db.

Can you please help me out for this?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/rtconner/laravel-tagging/issues/151, or mute the thread https://github.com/notifications/unsubscribe-auth/AAUaxRrs5ILXGaGyUEFii5L3oXj8zHDDks5t9lUigaJpZM4Uq1B7 .

virumandaliya commented 6 years ago

Thank you for quick response.

I have checked config file but I could not find settings related to first letter capital.

Can you please point out where actually I have to make the changes?

virumandaliya commented 6 years ago

hello,

any guidance please on above point?

rtconner commented 6 years ago

Look at this file https://github.com/rtconner/laravel-tagging/blob/laravel-5/config/tagging.php

You have two options, normalizer and displayer. You can modify either of those configs. Normalize is before write to database and displayer is used for front end display.

ferrarafer commented 4 years ago

Hi Rob, first of all, thanks for sharing this great package. I've been using it for a while.

I understand what you say to @virumandaliya, but when trying to modify the normalization, I realize that the function applies to both, name and slug, and I really think they are two different things.

Suppose that I want the names of the tags to be saved as they are written, but that the slug be saved as a typical slug, in lowercase and without spaces, I cannot do that. Any advice?

Example:

warmwhisky commented 4 years ago

I'm still confused on how you get it to not change your tags?

I have commented out both normalizer and displayer but I still get tags in the taging_tags table that are not in my model therefore it breaks some of my pages.

warmwhisky commented 4 years ago

Yep, confirmed I have no way of stopping it change my tags. I didn't realise it was doing this until I fully integrated it to my system and then had a product come back in stock "Gin and Tonic". sent out 50 back in stock emails only to get 500 server errors because the tags is exactly "Gin and Tonic" and NOT "Gin And Tonic"

With no direction on how you stop it changing tags, but to just look in config I am stuck with 500 errors.

rtconner commented 4 years ago

Don't have a config to turn off normalization, but you could just write a function that does nothing and set it as the displayer...

function do_nothing($str) { return $str; }
// don't edit the screen display value
'displayer' => '\do_nothing',

// don't edit the database slug
'normalizer' => '\do_nothing',

I could see how this could be a desired config, I'll try to add it but won't be this week.