如何使用 Drupal7 中的视图自定义节点/视图显示
我正在使用 drupal7,我创建了一个自定义内容类型(容器),其中包含一些字段,例如容器名称、公司、注册端口、一些日期(下载的日期模块),并且还有一个图像。我还创建了一个列出所有船只的视图,并检查了可用的表格、网格等解决方案,但它们没有满足我的需求。
我实际上想以某种方式“格式化”我的内容类型字段(船舶名称、公司、图像等)在显示节点以及显示视图本身时的显示方式。例如,我需要将图片放在左侧,并在其旁边放置一些字段(船舶名称、公司)(以表格或其他形式),而不是像默认情况下或以表格格式那样位于其下方如使用网格等选择时显示的那样...
这是我需要作为节点的示例:
---------------------------------------------------
| | <vessel name> | <port> |
| <image> | <vessel company> | |
| | | |
---------------------------------------------------
到目前为止,我已经使用了 cck (核心 drupal7)和视图。
我做了一些研究,发现一些帖子在某种程度上是我所需要的,但并没有真正帮助我。我知道我需要以某种方式修改一些 .tpl.php 文件并将它们放置(或替换)到正确的文件夹中,但我真的很困惑。鉴于我使用视图,我必须修改所有 .tpl.php 文件中的哪些以及将它们放置在哪里,并且我不确定是否必须将文件放置在 \theme 文件夹或 module\views\theme 中文件夹或任何其他文件夹。
我在 drupal 和 php 方面都是菜鸟,但有良好的软件工程背景,所以我相信我能赶上。
任何人都可以通过说几句话或提供一些从头开始做事情的链接/教程来提供帮助。我几乎明白这一切是如何工作的,但我想我错过了一些部分(可能对这一切都很关键)。
很抱歉这篇文章很长。
先感谢您
i'm using drupal7 and i have created a custom content type (vessel) which has some fields e.g. vessel name, company, reg port, some dates (downloaded date module) and has also an image. I have also created a view that lists all vessels and checked the available table, grid etc solutions but they re not covering my needs.
i actually want to "format" somehow the way the fields of my content type (vessel name, company, image etc) are displayed when a node is displayed and also when the views itself is displayed. So for example i need to have the picture on the left and some of the fields (vessel name, company) right next to it (in the form of a table or something) and not below it as it does by default or in tabular format as displayed when selected with grid etc...
here's an example of what i need to have as a node:
---------------------------------------------------
| | <vessel name> | <port> |
| <image> | <vessel company> | |
| | | |
---------------------------------------------------
so far i have used cck (core drupal7) and views.
i have done some research and found some posts that are somewhat what i need but not really helped me. I understand that i need to somehow modify some .tpl.php files and place (or replace) them on the proper folders but i'm really confused. Which of all the .tpl.php files do i have to modify and where to place them given that i use Views and i'm not really sure if i have to place the file inside a \theme folder or the modules\views\theme folder or any other folder.
i'm kind of noob in both drupal and php but have a good s/w engineering background so i believe i can catch up things.
Anyone can help by saying a few words or giving some links/tutorials that does things from scratch. I almost understand how all this thing works but i guess i miss some parts (probably critical of all this).
sorry for the long post.
thank you in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
用于渲染视图的模板列在视图版本 UI 的“主题信息”链接中。您可以通过将文件从 Views 模块文件夹复制到主题文件夹来覆盖主题中的模板。
但默认的视图模板非常冗长和完整。使用未格式化的样式和按显示顺序排列的四个字段(从左到右阅读时),您最终应该得到足够丰富的标记,无需额外的 PHP/HTML 代码即可在 CSS 中实现布局。
The templates used to render the views are listed in the "Theme Information" link in the Views edition UI. You can override the templates in your theme by copying the file from the Views module folder to your theme's folder.
But the default Views's template are very verbose and complete. Using the unformatted style and your four fields in display order (when reading from left to right), you should end up with a markup rich enough to achieve your layout in CSS without additional PHP/HTML code.
我会看一下这个模块,http://drupal.org/project/ds。
和此模块http://drupal.org/project/custom_formatters。
I would take a look at this module, http://drupal.org/project/ds.
and this module http://drupal.org/project/custom_formatters.