我想知道如何在网站中实现URL slug功能,而不会在URL中显示当前正在查看的记录的ID.
例如,StackOverflow URL如下所示:来自Url Slug的MVC动态视图.请注意,URL包含记录的ID.如果我要将此页面加入书签,并且由于某种原因记录的ID已更改,我将来无法查看此记录.
我想实现一个不依赖于记录ID的URL slug功能,所以它看起来像https://stackoverflow.com/questions/mvc-dynamic-views-from-url-slug.
你能否提供实现这一目标的步骤?你是否使用了唱片的标题并对其进行了缓和,保存了那个slug,再也没有改变它?
我正在寻找的示例网址是http://weblogs.asp.net/scottgu/archive/2010/10/04/jquery-templates-data-link-and-globalization-accepted-as-official-jquery -plugins.aspx(注意URL中没有ID)
谢谢!
当我在slug中打开带有连字符的URL时出现一个奇怪的错误,尽管SlugField支持连字符,如文档中所示.
所以,这是错误:
Page not found (404)
Request Method: GET
Request URL: http://127.0.0.1:8003/dumpster-rental-prices
Using the URLconf defined in dumpster.urls, Django tried these URL patterns, in this order:
^admin/
^(?P<slug>\w+)/$
The current URL, dumpster-rental-prices, didn't match any of these.
Run Code Online (Sandbox Code Playgroud)
如果我将文章的slug更改为dumpster_rental_prices - 网址127.0.0.1:8003/dumpster_rental_prices打开正常.
这是博客应用的models.py:
from django.db import models
class Post(models.Model):
title = models.CharField(max_length = 100)
body = models.TextField(max_length = 5000)
slug = models.SlugField(max_length = 100)
def __unicode__(self):
return self.title
Run Code Online (Sandbox Code Playgroud)
这是博客中的urls.py:
from django.conf.urls import patterns, include, url
from django.views.generic import DetailView, ListView
from blog.models …Run Code Online (Sandbox Code Playgroud) 在本地主机中,一切正常,但在部署项目后,我收到此错误
[Semantical Error] The annotation "@Gedmo\Mapping\Annotation\slug" in property
AppBundle\Entity\Product::$slug does not exist, or could not be auto-loaded.
Run Code Online (Sandbox Code Playgroud)
这是产品类
use Gedmo\Mapping\Annotation as Gedmo;
abstract class Prodcut
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=255)
*/
private $name;
/**
* @var string
* @Gedmo\slug(fields={"name"})
* @ORM\Column(name="slug", type="string", length=255, unique=true)
*/
private $slug;
Run Code Online (Sandbox Code Playgroud) 我正在使用angular-slugify从标题输入中制作一个 slug。但是有什么办法可以恢复它的标题吗?我是 angularjs 的新手,似乎没有用于恢复标题的资源。
更新
如何转换this-is-a-slug-title为This Is A Slug Titleinangularjs或javascript?作为初学者,它对我来说可能是先进的,但非常感谢您的帮助。
我有一个带有字段组的项目列表。组也是列表。我想显示按组分组的项目列表。该项目可以是两个或多个组的一部分。
\nList<Product> _items = [\n Product(\n id: \'1\',\n title: \'Apple and more more thing\', description: \'Some data to describe\',\n group: [\'Picnic\', \'New\'], price: 25, bonus: 1, quantity: 1.5, measure: \'\xd0\xba\xd0\xb3\', measureStep: 1.5,\n imageUrl: \'assets/fruits/orange.jpg\'),\n Product(\n id: \'2\',\n title: \'Apple and more more thing\', description: \'Some data to describe\',\n price: 24.50, bonus: 1, group: [\'Picnic\', \'New\'], quantity: 1.5, measure: \'\xd0\xba\xd0\xb3\', measureStep: 1.5,\n imageUrl: \'assets/fruits/orange.jpg\'),\n Product(\n id: \'3\',\n title: \'Apple and more more thing\', description: \'Some data to describe\',\n price: 5.00, …Run Code Online (Sandbox Code Playgroud) slug我的 TCA 中有字段,通常它可以工作,当通过后端> 列表模块添加时,即使我不会输入任何值,uniqueeval 也确保 slug 是唯一的,因此当我创建许多具有相同名称的行时富TYPO3后台将enshure,这将解决以独特的蛞蝓一样foo,foo-1,foo-2等荣誉!:
'slug' => [
'exclude' => true,
'label' => 'Slug',
'displayCond' => 'VERSION:IS:false',
'config' => [
'type' => 'slug',
'generatorOptions' => [
'fields' => ['name'],
'fieldSeparator' => '/',
'replacements' => [
'/' => '',
],
],
'fallbackCharacter' => '-',
'eval' => 'unique',
'default' => '',
'appearance' => [
'prefix' => \BIESIOR\Garage\UserFunctions\SlugPrefix::class . '->getPrefix'
],
],
],
Run Code Online (Sandbox Code Playgroud)
但是,当从我的表单中的new/create操作(如您所见,来自 extension_builder 的典型 …
我正在使用 Angular 8 版本创建一个新闻应用程序。我需要显示这样的链接:www.domain.com/category/category/title 和 www.domain.com/category。我怎样才能实现这个目标?
谢谢
slug ×7
angular ×1
angular8 ×1
angularjs ×1
dart ×1
django ×1
django-views ×1
extbase ×1
flutter ×1
frontend ×1
grouped-list ×1
hyphen ×1
javascript ×1
list ×1
symfony ×1
typo3 ×1
typo3-10.x ×1
url ×1
url-routing ×1