在drupal中以块的形式显示动态内容

发布于 2024-11-06 03:05:46 字数 243 浏览 1 评论 0原文

我是 drupal 的初学者。我正在为学生和教育机构开发一个网站,这些机构需要在一个页面中显示他们的信息。内容编辑器将添加机构信息(名称、描述、课程、设施、联系信息等),我想要一个树结构,用于按类别和名称列出机构。(它将位于左侧边栏中)

机构信息需要显示在不同的块中(例如右上角的联系信息 主要内容中的名称和描述,右侧是课程)。我不太了解观点。我知道如何创建区域并在其中放置内容。我可以使用 html 和 css 制作模板。我应该如何去实施这个。提前致谢。

I am a beginner in drupal. I am developing a site for students and educational institutes where the institutes need to display their information in a single page. A content editor will add an institutes info (name , description, courses, facilities, contact info etc) and I want to have a tree structure for listing institute by category and names.(It will be in left sidebar)

The institute info need to get displayed in different blocks (like contact info on top right
Name and description in main content , courses in right ). I am not very well versed with views. I know how to create regions and place content in there. I can make template using html and css. How should I go about implementing this. Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

最冷一天 2024-11-13 03:05:46

首先,您应该设置一个内容类型“Institute”,其中包含要显示的所有必要字段(正文、联系信息等)。然后创建一个单独的内容类型“课程”,并创建必要的字段。

要将课程与研究所联系起来,您应该确保 CT 研究所中有节点参考。这样,您就可以在创建学院期间链接课程。该字段有多种设置,包括自动完成、选择列表等。我认为它也应该设置为“多个”,因为我怀疑一个学院只会有 1 门课程。

配置您的 CT 机构的显示字段,以便它仅显示主内容窗口中所需的内容。您刚刚标记为隐藏的其他字段。

然后使用块显示创建一个视图。给它一个 Node:Nid 参数。并选择设置“提供默认参数”=>来自 url 的节点 ID。这样,当您查看机构 A(例如,节点 ID = 1 )时,机构 A 的节点 ID 将在视图中自动传递。进一步配置视图:按节点类型研究所限制它,并添加您选择在节点显示字段中隐藏的视图字段。因此,如果您选择隐藏“地址”,请将其作为字段添加到您的视图中。

如果您随后将 Institute 节点配置为始终具有路径“institue/[title]”(模块 Pathauto 可以为您执行此操作),则可以将块配置为仅显示在路径“institute/*”上,例如在左侧边栏中。

如果一切顺利,当您现在转到机构 A 时,您应该只能看到您在主窗口中选择的字段,所有其他字段都显示在左侧或右侧边栏的块中。

要为该特定学院设置课程视图,您还必须从 URL 添加参数 Node:Nid,但还必须添加关系。这是因为您不想在该块中显示学院字段,而是显示课程字段。如果设置正确,请不要忘记添加字段,并指示它们应该使用该关系。

我希望这对您的道路有所帮助!

First, you should set up a Content Type 'Institute', with all necessary fields you want to display ( main text, contact info, etc .. ). Then make a seperate Content Type 'Course', and create the necessary fields as well.

To hook up the Courses with the Institutes, you should make sure there's a Node Reference in the CT Institute. That way, you can - during Institute creation - link Courses. The field has several settings, including autocomplete, select list, etc .. I assume it should also be set up as 'multiple', because I doubt that an Institute will have only 1 Course.

Configure your CT Institue, Display fields, so that it only shows whatever's needed in the main content window. The other fields you just mark hidden.

Then create a view, using the Block display. Give it an argument of Node:Nid. And pick the setting 'Provide default argument' => Node ID from url. That way, when you are viewing Institue A ( which has for example Node ID = 1 ), the Node ID of Institute A will be passed on automatically in the View. Further configure the View : limit it by Node Type Institute, and add the View Fields that you chose as hidden in the Node Display fields. So if you chose to hide 'Address', add it as a field to your view.

If you then configure your Institute nodes to always have the path 'institue/[title]' ( the module Pathauto can do that for you ) , you can configure your Block to only display on the paths 'institute/*', and for example in the left sidebar.

If all went well, when you now go to Institue A, you should only see the fields you chose in the main window, with all other fields being display in a block on the left or right sidebar.

To setup a view with Courses for that specific Institute, you also have to add an argument Node:Nid from the URL, but you have to add a relationship as well. This is because you don't want to display Institute fields in that block, but rather Course fields. If this is setup correctly, don't forget to add the fields, and indicate that they should use the relationship.

I hope this will help you on your way!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文