我是否正确理解 Drupal 区域和视图?

发布于 2024-08-09 09:12:17 字数 362 浏览 11 评论 0原文

我们正在 Drupal 中构建一个内容非常丰富的网站。这是我第一次使用它。该网站有多个部分,每个部分都有不同的布局。我计划通过 phptemplate_preprocess_page() 方法确定 page.tpl.php 。

我的问题是如何最好地指定在给定页面中放置不同的辅助内容块的位置。我们有很多侧边栏类型的组件,每个组件都有几个小的列表或图像组。我认为最好的方法是根据需要定义多个区域,并将自定义视图(使用视图模块)放入这些区域中。这看起来合理吗?

更新:

关于将视图视为查询 - 让我困惑的是视图还可以选择修改其外观。我更希望能够从视图中获取节点数组,这样我就可以在 PHP 中操作数据,而不是格式化标记。这可能吗?

We're building a very content rich site in Drupal. It's my first time working with it. There are a variety of sections to this site, each with a different layout. I plan on determining the page.tpl.php via the phptemplate_preprocess_page() method.

My question is how best to specify where in a given page to put different chunks of secondary content. We've got a lot of sidebar type components, each with several small lists or groups of images. I think the best approach here is to define multiple regions as needed and drop in custom views (using the Views module) into these regions. Does that seem reasonable?

Update:

Regarding treating Views as queries - what confuses me is that the Views also have options to modify their appearance. I'd prefer if I could just get an array of nodes back from a View so I could operate on the data in PHP, rather than formatted markup. Is that possible?

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

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

发布评论

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

评论(3

淡淡離愁欲言轉身 2024-08-16 09:12:17

为了扩展 Rishavs(正确)答案,块是填充区域的“标准”元素。 page.tpl.php 中的区域定义了广泛的常规布局(例如标题、一些列/侧边栏和页脚 - 您需要的任何内容)。在一个区域内,您可能只放置一个东西(例如视图),但通常更多地以多个块的形式放置。它们在区域中出现的顺序由块权重决定。

您可以通过将块类型的显示添加到“基本”视图定义来直接在视图模块中创建块。此外,您定义的每个菜单都可以作为块使用。在自定义模块中创建自己的块也非常简单,使您可以完全控制其内容(请参阅hook_block() )。例如,通过这种方式,您可以将表单放入块中(标准 Drupal 安装的登录块就是一个示例)。

To expand a bit on Rishavs (correct) answer, blocks are the 'standard' element to fill regions. The regions in your page.tpl.php define the broad, general layout (e.g. a header, some columns/sidebars and a footer - anything you need). Within a region, you might place only one thing (e.g. a view), but usually more in the form of several blocks. The order in which they appear in the regions is determined by the blocks weight.

You can create blocks directly in the views module by adding displays of type block to a 'base' view definition. Also, every menu you define will be available as a block. It is also pretty straight forward to create your own blocks within custom modules, giving you full control over its contents (see hook_block() for this). That way, for example, you can put forms into blocks (the login block of a standard Drupal installation is an example for this).

你的他你的她 2024-08-16 09:12:17

是的,您可以使用自定义区域,并将自定义视图放入其中。

您甚至可以使用创建自定义块并在其中使用视图。

这取决于您所拥有的布局的结构。

Yes, you can use custom regions, and drop in custom views into them.

You can even use create custom blocks and use views in them.

It depends on the structure of the layout you have.

无尽的现实 2024-08-16 09:12:17

视图(内容列表)是数据库查询。区域是页面的一个区域(左侧边栏、页脚等)。区域在页面模板(tpl.php)中分配,并且会根据您使用的主题而有所不同。通常,辅助内容(包括但不限于视图)通过块放置。当块被分配到某个区域时(“右侧边栏”中的“新用户”),就会显示块。此外,视图还可以嵌入到页面模板中(无论是区域内还是区域外)。

A View (a list of content) is a database query. A region is an area of the page (left sidebar, footer, etc.). Regions are assigned in the page template (the tpl.php's) and will vary depending on the theme you are using. Typically, secondary content (including, but not limited to, Views) is placed via blocks. Blocks are displayed when they are assigned to a region ("New Users" in the "Right Sidebar"). Also, Views can also be embedded in a page template (either inside out outside of a region).

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