du9698 2009-06-03 13:38
浏览 49
已采纳

如何以编程方式为Drupal Node Links(没有PathAuto)输出自定义路径?

I would like to be able to programmatically change the outputted path to a Drupal node without using the PathAuto module. We currently process a large volume of content (thousands of articles per day) that get added on the back-end. Rather than use PathAuto to generate path aliases, I would like to have Drupal output the default link but append a partial title for better SEO.

An example of this would be:

/node/123

would be changed to

/node/123/This-is-the-article-title (this path currently will work for the existing node)

I understand how to do this on a theme-basis, by modifying the theme/view templates, but I would like to do it so that anytime the link to the node is displayed anywhere, it adds the title plug.

In addition, I would like to limit it to a certain content type (e.g., 'article').

I am using Drupal 5.x and I would prefer not to use PathAuto (I don't want to store hundreds of thousands of path aliases if not necessary)

I am looking for a solution that does not use PathAuto

  • 写回答

3条回答 默认 最新

  • dongtun2572 2009-06-03 16:57
    关注

    Drupal has an internal mechanism for mapping from "/node/1234/" to "/blogs/look-at-what-my-cat-just-did". It's part of the core system, and used almost everywhere, on every request, without you even having to ask. It's fast enough you'll almost never notice it happening - there's plenty of other things in drupal that are -far- slower.

    If you're concerned about how URLs are being displayed on the front-end - you should be using the url() function (and filters that do the same with node content) to handle look-ups going the other way.

    Where Pathauto comes in is that, when you create or edit content, it will generate a number of entries in Drupal's url_alias table (based on whatever pathauto rules you've created). This is a one-time cost. Unless you're generating content at an astronomical rate - there is a negligible cost associated with doing this.

    You're already paying the cost of looking up URL aliases by simply using Drupal. Without hacking core, you can't really avoid it. Storing "hundreds of thousands of path aliases" in the database isn't that big of a deal - if you break that down into the actual storage requirements, you're only looking at a handful of megabytes. Since the table's well indexed, look-ups will be virtually instantaneous. This is core functionality & happens regardless of Pathauto even being on your system.

    Unless you have some very odd requirements for the types of URLs you want to map your nodes to, anything you do will simply be recreating a subset of Pathauto's existing functionality (and likely introducing a bunch of new bugs).

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥120 计算机网络的新校区组网设计
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据