slug

CakePHP - How to do reverse routing with slug?

喜欢而已 提交于 2019-12-01 03:23:37
问题 I am using CakePHP 1.3. I have a Product model. on the DB table among others there are id and slug fields. If I have a product that is id:37 and slug:My-Product-Title I want the URL for the product to be: products/37/My-Product-Title Instead of the standard: products/view/37 I created a route that looks like this: Router::connect( '/products/:id/:slug', array('controller' => 'products', 'action' => 'view'), array('pass' => array('id'), 'id' => '[0-9]+') ); Now I can go to http://server

Better SEO to remove “stop” words from an article's URL Slug?

a 夏天 提交于 2019-11-30 22:10:51
I saw a Wordpress plugin that removes certain words from an articles URL Slug. So for an example, without the plugin, if I create an article titled... Organize Your Projects into Boards with the Trello App then Wordpress would automatically create this URL Slug... organize-your-projects-into-boards-with-the-trello-app Now if I were to use the Plugin that removes "stop" words, it would instead create this URL slug... organize-projects-boards-trello-app Now my question, the plugin's description says that it is better for SEO, I am curious if others feel this is better to remove words like that

Django: Slug in Vietnamese

混江龙づ霸主 提交于 2019-11-30 15:22:18
A site in Vietnamese, it is virtually no different to English. However, there is a problem that is slug. When I type characters such as "ư", "ơ", "á",... Django is not identified. Solution here is to replace characters that do not sign into. Eg: ư -> u ơ -> o á -> a One from "những-viên-kẹo" will become "nhung-vien-keo". However, I do not know how to do this. Someone help me. Thank you very much! [edit] I take it back, django's django.template.defaultfilters.slugify() does what you want, using unicodedata.normalize and .encode('ascii', 'ignore') . Just feeding your string into slugify will

Fetching records with slug instead of ID

谁说我不能喝 提交于 2019-11-30 14:29:13
I'm currently trying to find the best way (in term of usability and performance) when dealing with a situation like fetching records tagged with a specific tag, or category, or something like that. A good way (the way I wanted to do), would be to fetch records with the tag/category slug, so the URL would look like : http://stackoverflow.com/questions/tagged/language-agnostic fetching records by slug, which looks better than : http://stackoverflow.com/questions/tag/789/language-agnostic fetching by ID and adding the slug behind so it's more search-engine friendly. This one is better performance

How to make Django create slug from unicode characters?

爷,独闯天下 提交于 2019-11-30 13:35:07
问题 Django Unicode Slug how to ? class NewsModel(models.Model): title = models.CharField(max_length = 300) slug = models.CharField(max_length = 300) content = models.TextField() def save(self,*args, **kwargs): if self.slug is None: self.slug = ??? super(NewsModel, self).save(*args, **kwargs) def get_absolute_url(self): return reverse("news_view", kwargs = {"slug" : self.slug, } ) 回答1: Django comes with a function for that: In [11]: from django.template.defaultfilters import slugify In [13]:

What is the best way to store a unique URL Slug?

泪湿孤枕 提交于 2019-11-30 10:08:11
I'm trying to generate some url 'slugs' for my website. It's based upon a single piece of user generated text. Now, i have made my own slug method, so i'm not after some code for that. What i'm wondering is where is the best place to determine if this slug is unique and then insert it because the slug field is a Unique Key Index. Originally, i had a trigger on any insert (against the table) so when the data is entered, the slug is then determined. I had a function that checked for the number of records that contained the user's text (not the slug) and then generated the slug and added the

How to make Django create slug from unicode characters?

醉酒当歌 提交于 2019-11-30 07:27:25
Django Unicode Slug how to ? class NewsModel(models.Model): title = models.CharField(max_length = 300) slug = models.CharField(max_length = 300) content = models.TextField() def save(self,*args, **kwargs): if self.slug is None: self.slug = ??? super(NewsModel, self).save(*args, **kwargs) def get_absolute_url(self): return reverse("news_view", kwargs = {"slug" : self.slug, } ) e-satis Django comes with a function for that: In [11]: from django.template.defaultfilters import slugify In [13]: slugify(u'ç é YUOIYO ___ 89098') Out[13]: u'c-e-yuoiyo-___-89098' But really your are better off using

Better SEO to remove “stop” words from an article's URL Slug?

拥有回忆 提交于 2019-11-30 05:21:49
问题 I saw a Wordpress plugin that removes certain words from an articles URL Slug. So for an example, without the plugin, if I create an article titled... Organize Your Projects into Boards with the Trello App then Wordpress would automatically create this URL Slug... organize-your-projects-into-boards-with-the-trello-app Now if I were to use the Plugin that removes "stop" words, it would instead create this URL slug... organize-projects-boards-trello-app Now my question, the plugin's description

What is the alphanumeric id in a reddit URL?

為{幸葍}努か 提交于 2019-11-30 05:07:44
What is the 7n5lu in the reddit URL http://www.reddit.com/r/reddit.com/comments/7n5lu/man_can_fly_if_you_watch_one_video_in_2 ...and how is it generated? Update: @Gerald, I initially thought this is some obfuscation of the id. It is just doing the conversion from integer to a more compact representation. I am thinking, why is this being done? why not use the original integer itself!! >>> to36(4000) '334' >>> to36(4001) '335' Gerald Kaszuba The reddit source code is available ! Here is what I found for generating that string: def to_base(q, alphabet): if q < 0: raise ValueError, "must supply a

ID + Slug name in URL in Rails (like in StackOverflow)

守給你的承諾、 提交于 2019-11-30 01:57:27
I'm trying to achieve URLs like this in Rails: http://localhost/posts/1234/post-slug-name with both ID and slug name instead of either http://localhost/posts/1234 or http://localhost/posts/post-slug-name (right now I have just slug name in URL, so this part is over). How can I do this? UPD I found an article on this: http://augustl.com/blog/2009/styling_rails_urls/ , instead of /id/slug it suggests to use /id-slug which works perfectly for me, so I'll go with this. You'll want to add a regular route with Route Globbing in addition to your resource route (assuming of course that's how your