Drupal 7:路径分级分类术语模式 [英] Drupal 7: Pathauto hierarchical taxonomy terms pattern

查看:184
本文介绍了Drupal 7:路径分级分类术语模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据以下方案,我有一个Drupal 7.9分类词汇:

  category-1 
category-1 >子类别1-1
category-1>子类别1-2
category-1>子类别1-3
category-2
category-2>子类别2-1

我想在我的页面网址路径中反映此分类层次结构,如

  category-1 / subcategory-1-1 / page-123 
/ pre>

为了实现这一点,我使用的是Modu Pathauto版本7.x-1.0。但我不知道
我必须使用哪种模式。



目前我正在使用 [node:%field_taxonomy%] / [node:title] 但是使用此模式,url路径只是子类别1-1 / page-123 ,所以不反映完整的层次结构。 是否有分类树模式?我找不到任何有关此更新的信息,并且每个版本的Pathauto都会更改有效的模式。

解决方案

经过一些尝试和错误,我想出了一种在我使用分类术语创建自定义URL路径时对我有用的方法。所有您需要做的是安装一个称为Entity API的附加模块。您可以在这里找到 http://drupal.org/project/entity 。安装后,您应启用Entity API和Entity令牌模块。实体令牌为所有没有令牌并且为实体API所知的属性提供令牌替换。



首先,创建一个新的分类词汇。我们称之为类别并添加一些术语。然后,对于要创建自定义URL路径的内容类型,您需要创建一个新的术语参考字段。我不知道为什么,但它并不适用于标准的field_tags。所以,确保创建一个新的。我们也叫它类别,并使用我们以前创建的词汇类别作为来源。另外你需要考虑一下:你必须用一个小写标记这个字段;否则它不为我的理由不明白;)。你会得到一个field_category字段。



转到URL别名管理页面 - >模式。展开内容路径的替换模式 - >展开节点 - >您将在底部看到类别,展开它。好的,现在你已经准备好使用分类术语令牌了。



使用类似[node:field-category:name] / [node:title]字段类别:名称]是分类术语的名称,您将有一个像mysite.com/term/title这样的路径。



顺便说一句,我使用Pathauto 7.x-1.0-beta1,令牌7.x-1.0-beta2和Entity API 7.x-1.0-beta8。



祝你好运! ))



http:// drupal。 org / node / 1044980#comment-4562844



您可以使用此模式创建URL:
[node:field-category:vocabulary:name ] / [node:field-category:parents:join:/] / [node:field-category:name] / [node:title]


I have a Drupal 7.9 taxonomy vocabulary according to the following scheme:

category-1
    category-1 > subcategory-1-1
    category-1 > subcategory-1-2
    category-1 > subcategory-1-3
category-2
    category-2 > subcategory-2-1

I want to reflect this taxonomy hierarchy in my page url path like

category-1/subcategory-1-1/page-123

To achieve this I'm using the modul Pathauto version 7.x-1.0. but I don't know which pattern I have to use.

Currently I'm using [node:%field_taxonomy%]/[node:title] but with this pattern the url path is just subcategory-1-1/page-123, so the complete hierarchy isn't reflected. Is there a taxonomy tree pattern? I can't find any updated information about this and valid patterns seem to change in every version of Pathauto.

解决方案

After some trial and error I came up with a way which works pretty good for me while creating custom URL paths using taxonomy terms. All you need to do is to install an additional module called Entity API. You can find it here http://drupal.org/project/entity. After installing you should enable both Entity API and Entity tokens modules. Entity tokens provides token replacements for all properties that have no tokens and are known to the entity API.

First, go and create a new taxonomy vocabulary. Let's call it "Category" and add some terms. Then for a content type you want to have a custom URL path you need to create a new term reference field. I don't know why but it's not working with the standart field_tags. So, make sure to create a new one. Let's also call it category and use our previously created vocabulary "Category" as the source. And here's another thing you need to take into account: you have to label this field with a small letter; otherwise it's not working for an unknown to me reason ;). You'll end up with a field_category field.

Go to URL Aliases administration page -> Patterns. Expand replacement patterns for Content paths -> expand Nodes -> you'll see category at the bottom, expand it. Ok, now you're ready to use taxonomy terms tokens.

Use something like [node:field-category:name]/[node:title] where [node:field-category:name] is the name of the taxonomy term and you'll have a path like mysite.com/term/title.

By the way, I use Pathauto 7.x-1.0-beta1, Token 7.x-1.0-beta2 and Entity API 7.x-1.0-beta8.

Good Luck! ))

http://drupal.org/node/1044980#comment-4562844

You can create url with this pattern: [node:field-category:vocabulary:name]/[node:field-category:parents:join:/]/[node:field-category:name]/[node:title]

这篇关于Drupal 7:路径分级分类术语模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆