内容类型显示帮助

发布于 2024-09-12 12:37:34 字数 1075 浏览 1 评论 0原文

我是 Drupal 的新手,我正在尝试弄清楚如何主题化内容类型。我正在为客户构建一个房地产经纪人网站,我的主要内容类型将类似于“房产列表”。我已经安装了所有必要的模块来帮助我上传图像,并且一切正常。我需要能够显示全尺寸图像和缩略图图像 - 以便为每个属性创建幻灯片(或图库)。

示例:

// Fullsize Images
<ul class="gallery-output">
    <li><img src="example.png" /></li>
    <li><img src="example-two.png" /></li>
</ul>
// Thumbnail Images
<ul class="gallery-nav">
    <li><a href="#"><img src="example_thumb.png" /></a></li>
    <li><a href="#"><img src="example-two_thumb.png" /></a></li>
</ul>

我现在知道您必须创建一个 node-[content-type].tpl.php 文件才能进行更改。我不知道在哪里。所以请帮助我。

在我复制的 node-whatever.tpl.php 文件中,我有:

<div class="content clear-block">
    <?php print $content ?>
</div>

我是否删除它并将其替换为我自己的自定义解决方案?或者我应该在 template.php 文件中进行更改吗?如果两者都可行,哪个是首选解决方案? 我正在使用:cck、filefield、imageapi、imagecache 和 imagefield。如果改变预处理函数是解决方案,那么追踪正确函数的最佳方法是什么?

请帮忙! (哦,如果有人说“使用视图”,我想我会发疯 - 所以请不要这样做,这不是我正在寻找的解决方案):)

I am new to Drupal and I am trying to figure out how to theme a Content Type. I am building a Realtor site for a client whereby my main content type will be something like 'Property Listing'. I have installed all the necessary modules to help me upload images and everything works properly. I need to be able to display BOTH the Fullsize and Thumbnail images - as to create a slideshow (or gallery) for each property.

Example:

// Fullsize Images
<ul class="gallery-output">
    <li><img src="example.png" /></li>
    <li><img src="example-two.png" /></li>
</ul>
// Thumbnail Images
<ul class="gallery-nav">
    <li><a href="#"><img src="example_thumb.png" /></a></li>
    <li><a href="#"><img src="example-two_thumb.png" /></a></li>
</ul>

I now know that you must create a node-[content-type].tpl.php file to make changes. What I do not know is where. So please help me.

In my copied node-whatever.tpl.php file I have:

<div class="content clear-block">
    <?php print $content ?>
</div>

Do I remove this and replace it with my own custom solution? Or do I make my changes in the template.php file? If both are possible, which is the preferred solution?
I am using: cck, filefield, imageapi, imagecache, and imagefield. If changing a preprocess function is the solution, what is the best method of tracking down the correct one??

Please help! (Oh and if somebody says 'Use Views' I think I'll go insane - so please don't, its not the solution I'm looking for) :)

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

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

发布评论

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

评论(2

写给空气的情书 2024-09-19 12:38:02

在您的 node-[content-type].tpl.php 文件中,将:替换

<div class="content clear-block">
  <?php print $content ?>
</div>

为:

<div class="content clear-block">
<?php

    // Large and Thumbnail are my Imagecache Presets

$cck_images = $node->field_image;
if (count($cck_images) > 0) :
  // Fullsize
  foreach ($cck_images as $cck_image) :
    $image = theme('imagecache', 'large', $cck_image['filepath'], $cck_image['data']['alt'], $cck_image['data']['title']);
    print $image;
  endforeach;
  // Thumbnails
  foreach ($cck_images as $cck_image) :
    $image = theme('imagecache', 'thumbnail', $cck_image['filepath'], $cck_image['data']['alt'], $cck_image['data']['title']);
    print $image;
  endforeach;
endif;

?>

<?php // All Content except for images ?> 
<?php print $content ?>
</div>

并从显示中排除图像(管理 -> 内容类型 -> 您的 [内容类型] -> 管理字段 -> )显示字段)。

相应地设计您的图像!

In your node-[content-type].tpl.php file, replace:

<div class="content clear-block">
  <?php print $content ?>
</div>

with:

<div class="content clear-block">
<?php

    // Large and Thumbnail are my Imagecache Presets

$cck_images = $node->field_image;
if (count($cck_images) > 0) :
  // Fullsize
  foreach ($cck_images as $cck_image) :
    $image = theme('imagecache', 'large', $cck_image['filepath'], $cck_image['data']['alt'], $cck_image['data']['title']);
    print $image;
  endforeach;
  // Thumbnails
  foreach ($cck_images as $cck_image) :
    $image = theme('imagecache', 'thumbnail', $cck_image['filepath'], $cck_image['data']['alt'], $cck_image['data']['title']);
    print $image;
  endforeach;
endif;

?>

<?php // All Content except for images ?> 
<?php print $content ?>
</div>

And exclude the images from the display (administer -> content type -> your [content-type] -> manage fields -> display fields).

Style your images accordingly!

痴情 2024-09-19 12:37:57

您使用 node-whatever.tpl.php 的方法是绝对正确的。 $content 保存处理时的COMPLETE 内容。如果您想设置 CCK 字段或类似字段的样式,则需要获取这些变量。页面上存在这些内容,只是不会向您显示,因为所有内容都在 $content 内。

作为一个好的帮助,请安装 Devel 和(更重要的)主题开发人员。主题开发人员允许您检查网站上可用的所有变量、调用什么块、使用哪些函数来渲染哪个部分等等。这非常有帮助。您将看到您拥有所需的所有数据,并且可以根据需要使用它们。

如果您想根据 ImageCache 设置调整某些图像的大小,您可以在模板中使用它,类似于:

theme('imagecache', 'your_preset', $field_fromcck[0]['filepath']);

假设您有一个名为 fromcck 的 CCK 字段。但是,当您熟悉 Devel 和 Theme Developer 后,您将可以使用此信息。

Your approach with node-whatever.tpl.php is absolutely correct. $content holds the COMPLETE content as it is processed. If you want to style your CCK fields or alike, you need to get these variables. There are present on the page, it is just not shown to you since everything is inside $content.

As a good help please install Devel and (more important) Theme Developer. Theme developer allows you to inspect ALL variales available on the site, what block are called, which functions are used to render what part and so on. This is very helpfull. You will see that you have all your desired data available and you can work with it just as you want.

If you want to resize some images according to a ImageCache setting, you use it inside the template similar to this:

theme('imagecache', 'your_preset', $field_fromcck[0]['filepath']);

Assuming you have a CCK field that is names fromcck. But this info will be availale to you after you made yourself familiar with Devel and Theme Developer.

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