slug

Slug urls with Ember.js

喜夏-厌秋 提交于 2019-12-02 00:42:28
问题 How would you get post/my-title (with a custom slug) instead of posts/2 (with id) in Ember.js? My approach was to add and use a slug in my model but it doesn't work on direct access. Using a {{link-to}} helper it works, also the slug. I assume the error lies in the PageRoute 's model. Tried return this.store.find('page', {'slug': params.page_slug}) without any luck. Example code: http://emberjs.jsbin.com/AVAgUZAb/5/edit 回答1: You're mismatching versions of Ember Data. In the PageRoute you are

TYPO3 9.5.2 Slug: Multilanguage: Page not found 404 exception, if no translation of page exists

浪子不回头ぞ 提交于 2019-12-01 23:33:59
I have a website with two languages e.g de and en. De is my default language with no path prefix. En, the second language, has /en/ as prefix in the url. Now when I switch to the en language, the menu item links have /en/ in the url, which is fine. But when I click on a menu item, which is not explicit translated in the backend, then I get a 404 error. I cannot say this behavier is wrong, because there isn't a page with this slug path before I create one. But what should I do? Create a translation for each page, which is not helpful, if there are already hundreds of pages. Is there no fallback

Generating doctrine slugs manually

邮差的信 提交于 2019-12-01 21:38:30
I'm using sluggable behavior in my Symfony2 project, but now I would like to make many slugs for one page, based on different texts (current title, old title(s), users text from form input), and keep it in another table. And my question is - how to manually use doctrine extensions for any text? I can't find it anywhere. Perfect would be something like: /* careful - it's not a real, working code! */ $sluggable = new DoctrineSluggable(); $slug = $sluggable->generate('My own text!'); echo $slug; // my-own-text Radzikowski I found solution by accident here . Code: use Gedmo\Sluggable\Util as

Slug urls with Ember.js

梦想与她 提交于 2019-12-01 21:22:46
How would you get post/my-title (with a custom slug) instead of posts/2 (with id) in Ember.js? My approach was to add and use a slug in my model but it doesn't work on direct access. Using a {{link-to}} helper it works, also the slug. I assume the error lies in the PageRoute 's model. Tried return this.store.find('page', {'slug': params.page_slug}) without any luck. Example code: http://emberjs.jsbin.com/AVAgUZAb/5/edit You're mismatching versions of Ember Data. In the PageRoute you are using the model definition to try and find the record which is no longer correct. See https://github.com

Creating Slugs from Titles?

可紊 提交于 2019-12-01 17:24:08
I have everything in place to create slugs from titles, but there is one issue. My RegEx replaces spaces with hyphens. But when a user types "Hi there" (multiple spaces) the slug ends up as "Hi-----there". When really it should be "Hi-there". Should I create the regular expression so that it only replaces a space when there is a character either side? Or is there an easier way to do this? I use this: yourslug.replace(/\W+/g, '-') This replaces all occurrences of one or more non-alphanumeric characters with a single dash. Just match multiple whitespace characters. s/\s+/-/g It might be the

Creating Slugs from Titles?

↘锁芯ラ 提交于 2019-12-01 16:12:46
问题 I have everything in place to create slugs from titles, but there is one issue. My RegEx replaces spaces with hyphens. But when a user types "Hi there" (multiple spaces) the slug ends up as "Hi-----there". When really it should be "Hi-there". Should I create the regular expression so that it only replaces a space when there is a character either side? Or is there an easier way to do this? 回答1: I use this: yourslug.replace(/\W+/g, '-') This replaces all occurrences of one or more non

How to enable arabic slug in htaccess?

耗尽温柔 提交于 2019-12-01 13:49:13
I have a multi-languages website, and I'm trying to create a friendly URL. In my database, I have the slug field. When the article's title is in english the slug appear in url and redirection works fine. but when the title is arabic the slug appear and the redirection shows " Object not found " page. what seems to be the problem guys ? please help I'm stack. Most likely the issue is your rewriting rule. It explicitly is crafter such that it only gets applied for requests that consist of only ascii characters, an underscore or a hyphen in the slug part of the URL. That obviously won't match

MySQL Insert row, on duplicate: add suffix and re-insert

◇◆丶佛笑我妖孽 提交于 2019-12-01 06:28:52
My question is rather complex, but I thought I should give it a try. In short, I want to insert a row with a slug (short string with alphas and a dash: this-is-a-slug). The problem is that slug is a unique key and there might be duplicates. When there is a duplicate it should be inserted with a modified slug , like with a suffix: this-is-a-slug-1, if that fails increase the suffix: this-is-a-slug-2. Here's the tricky part, it should be accomplished in MySQL (no PHP involved) and preferably in a INSERT statement (no variables, procedures etc.) I've tried a simple solution like so: INSERT INTO

CakePHP - How to do reverse routing with slug?

心已入冬 提交于 2019-12-01 05:54:55
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/products/37/My-Product-Title and it takes me to the right place. But How do I get reverse routing to

MySQL Insert row, on duplicate: add suffix and re-insert

帅比萌擦擦* 提交于 2019-12-01 03:32:02
问题 My question is rather complex, but I thought I should give it a try. In short, I want to insert a row with a slug (short string with alphas and a dash: this-is-a-slug). The problem is that slug is a unique key and there might be duplicates. When there is a duplicate it should be inserted with a modified slug , like with a suffix: this-is-a-slug-1, if that fails increase the suffix: this-is-a-slug-2. Here's the tricky part, it should be accomplished in MySQL (no PHP involved) and preferably in