简体   繁体   English

Drupal-视图中选定节点的突出显示

[英]Drupal - Selected Node Highlighting in Views

Drupal Question: Drupal问题:

Does anyone have a method of using Views and highlighting a selected/current node. 有没有人有使用视图并突出显示选定/当前节点的方法。

So for example: 因此,例如:

I have a list of articles under a heading: 我的标题下有文章列表:

2009 Articles 2009年文章

Dog Training 狗训练

Cat Cleaning 猫清洁

Snake Wrangling 蛇争吵

The 3 articles are made from the view (ie: latest articles from 2009)... as the user makes new articles, they are automatically added into this view by title. 这3个文章是从视图中制作的(即:2009年以来的最新文章)...当用户制作新文章时,它们会按标题自动添加到该视图中。

I now need to find a way, that if a user clicks on say CAT CLEANING.... and the cat cleaning article appears, the CAT CLEANING in the view becomes bold (or some CSS indication it's the current article.) 我现在需要找到一种方法,如果用户单击说CAT CLEANING ....,并且出现了猫清洁文章,则视图中的CAT CLEANING变为粗体(或某些CSS指示它是当前文章。)

I know this is pretty easy with MENU's, But I don't want to force a user to add new articles into a menu. 我知道使用MENU菜单很容易,但是我不想强迫用户向菜单中添加新文章。

Thanks alot, JD 非常感谢JD

  1. In the Context Filters, add "Global:null" and select "Get content ID from URL" 在上下文过滤器中,添加“ Global:null”,然后选择“从URL获取内容ID”
  2. Add a NID field and set "Exclude from display" 添加一个NID字段并设置“从显示中排除”
  3. Add a Mathematic field who evaluate difference between the both NID : "!1-[nid]"and set "Exclude from display" 添加一个计算两个NID之间的差异的数学字段:“!1- [nid]”,然后设置“从显示中排除”
  4. Add a class to the field to highlight as "active[expression]" where active0 is the class of the current node. 将一个类添加到字段中以突出显示为“ active [expression]”,其中active0是当前节点的类。

There is the video tutorial to achieve that: http://youtu.be/0uSfuVmO6zk 有实现该目标的视频教程:http: //youtu.be/0uSfuVmO6zk

您可以覆盖正在使用的任何Views模板(通过单击“视图”编辑页面上的“主题:信息”链接来执行此操作),并基本上说“如果此节点的链接与当前查看的路径相同,则添加一个'当前的课程”。

Here is what you need to do: 这是您需要做的:

  1. Look up the class of the view list item (eg Dog training) using Firebug 使用Firebug查找视图列表项的类(例如,狗训练)
  2. Add CSS for the view list item manually in the theme folder or using something more convenient like the css injector module 在主题文件夹中手动添加视图列表项的CSS或使用CSS注入器模块等更方便的工具
  3. The CSS will be something like this CSS将是这样的

    .view-name .view-name-of-field-here a:active {text-decoration: underline; .view-name .view-name-of-field-here a:active {text-decoration:underline; color: red} 红色}

Here we are using the "active" CSS pseudo class to color and underline the link if the URL in the view list item is the same URL as the web page. 如果视图列表项中的URL与网页相同,则此处使用“活动” CSS伪类对链接进行着色和下划线。

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

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