dongtuo8170 2012-08-28 19:00
浏览 128
已采纳

Drupal 7将内容类型url设置为自定义值

I am using Drupal 7 and have created a custom content type and a view that displays those content types. What I want to do is override the url to the node in the teaser view. My specific use case is this:

I have a support view that displays support content types. When I view that page, I see the teasers for the support content types I have created: Safety, FAQ, Ticketing. Safety and FAQ link to their nodes as expected. What I am trying to accomplish, is have the teaser and image for ticketing there, but have it link to my external ticketing portal. Essentially, I would like to have a checkbox when creating content of this type that allows me to link to external url. I do have the link module installed, but there is no way for me to apply that field to the url of the title.

I have spent a while googling around trying to find the answer, but without much success. If there is nothing available to do this already, I wouldn't mind building a module and submitting it to the community. Just want to make sure I'm not missing anything.

Thanks in advance.

UPDATE

Here are the steps I took using the answer given below:

  1. Install the link module: http://drupal.org/project/link
  2. Create a content type, add a field for link
  3. Add new content of that type and add the url you want to link to in the link field
  4. Create a view and filter by that content type
  5. Under format, i'm using format: "grid" with show: "fields"
  6. Add a field for the Content: link field you created FIRST* in the list. Set to Exclude from display and Formatter: URL, as plain text
  7. Add a title field and deselect "Link this field to the original piece of content" click on "rewrite results" and select "rewrite the output of this field". Enter <a href="[field_link_to]">[title]</a> in the text field where [field_link_to] is the name of the link field as described in the "replacement patterns" dropdown below it.
    • If you do not have the link field in your list of fields FIRST, the token will not be available to the fields below it.
    • In your Content Type > Manage Fields > Link (edit) > Wrapper markup, make sure "no markup" is selected
  • 写回答

2条回答 默认 最新

  • dqqfuth6736 2012-08-28 19:14
    关注

    You can alter the display of the view using the rewrite options. Make sure your display type is set to 'fields'. Then include the fields you want to display; title, teaser, image.

    In the field configuration of the title field, choose 'rewrite results'. there you can enter the following <a href="example.com">[title]</a> That should overrule the title.

    Also make sure to uncheck 'link the field to it's node'.

    UPDATE: You might have to create a second view for this... To prevent editing the other two elements.

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

报告相同问题?

悬赏问题

  • ¥15 孟德尔随机化结果不一致
  • ¥15 深度学习残差模块模型
  • ¥20 两个不同Subnet的点对点连接
  • ¥50 怎么判断同步时序逻辑电路和异步时序逻辑电路
  • ¥15 差动电流二次谐波的含量Matlab计算
  • ¥15 Can/caned 总线错误问题,错误显示控制器要发1,结果总线检测到0
  • ¥15 C#如何调用串口数据
  • ¥15 MATLAB与单片机串口通信
  • ¥15 L76k模块的GPS的使用
  • ¥15 请帮我看一看数电项目如何设计