简体   繁体   English

Drupal,基本的字符串转换功能

[英]Drupal, basic string conversion function

Could somebody tell me the name of function that convert spaces to underscores and letters to lowercase for seo friendly uri's? 有人可以告诉我SEO友好URI的将空格转换为下划线并将字母转换为小写的函数的名称吗?

I know it's very easy function to implement but I want use function for this job if exists in Drupal already. 我知道这是一个非常容易实现的函数,但是如果Drupal中已经存在,我想为该工作使用函数。

Regards 问候

I'm not sure what you are trying to accomplish, but you can do a lot with the pathauto module and clean urls. 我不确定您要完成什么,但是您可以使用pathauto模块和干净的url做很多事情。

Unless you are actually creating a custom module that will create your own url, the above mentioned configuration is pretty simple. 除非您实际上正在创建一个将创建自己的url的自定义模块,否则上述配置非常简单。 If you are making a custom module, I have a pretty strong suspicion that making a nice URL would be core functionality. 如果您要创建自定义模块,我会非常怀疑创建一个不错的URL是核心功能。

As LanguaFlash said, if you just need to auto-generate SEO-friendly URLs for your content, use Pathauto : that's what it was made for. 正如LanguaFlash所说,如果您只需要为内容自动生成SEO友好的URL,请使用Pathauto :这就是它的用途。 Even if you have your own custom module with custom paths, you can hook into Pathauto's API to do all the URL generation for you. 即使您拥有自己的带有自定义路径的自定义模块,也可以连接到Pathauto的API来为您完成所有URL生成。

That said, if you really need to throw caution to the wind generate your own clean URLs by yourself, think about creating a dependency on Pathauto and utilizing its two URL cleaning functions— pathauto_cleanstring() and pathauto_clean_alias() —which are used by Pathauto to do what you're trying to do. 就是说,如果您确实需要谨慎地自己生成自己的干净URL,请考虑创建对pathauto_cleanstring()的依赖关系,并利用pathauto_cleanstring()使用其两个URL清理函数pathauto_cleanstring()pathauto_clean_alias()来做你想做的事。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM