Drupal/Ubercart ...节点样式?

发布于 2024-07-21 07:30:41 字数 534 浏览 5 评论 0原文

我正在尝试在 Drupal 站点上设置产品视图的样式,但遇到了问题。 我找不到节点(产品)视图在 ubercart 中的组合位置!

我使用的是 UC 5.x-1.7,我需要设置节点(产品)视图页面的样式。 目前在我的node.tpl.php 文件中,我有

print $body;
which spits out all the SKU, attributes, price, picture etc.

问题是我需要采用不同的风格 - 我必须按照设计师完成的设计进行工作。 我已经开始重新做我自己的版本,使用像这样的变量

$node->content['body']['#value']
etc.

我在尝试使用产品的各种属性时遇到了麻烦。 我找不到如何将它们放到我的页面上,也找不到任何有关如何从编码员的角度使用它们的文档。

有更容易的方法吗? 我应该在哪里设置现有显示的样式(即 $body 变量)?

编辑:我的主题基于禅宗主题

I am trying to style the product view on a Drupal site, but am having problems. I can't find where the node (product) view is put together in ubercart!

I'm using UC 5.x-1.7, and I need to style the node (product) view page. At the moment in my node.tpl.php file, I have

print $body;

which spits out all the SKU, attributes, price, picture etc.

The problem is I need to have this in a different style - I have to work to a design done by a designer. I have started re-doing my own version, using the variables like

$node->content['body']['#value']

etc.

I have run into trouble trying to work with the various attributes for a product. I can't find out how to get them onto my page, or any documentation on how to work with them from a coder's point of view.

Is there an easier way? Where would I look to style the existing display (i.e. the $body variable)?

Edit: my theme is based on the Zen Theme

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

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

发布评论

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

评论(4

内心激荡 2024-07-28 07:30:41

如果问题纯粹是样式,您可以编写自己的 CSS 来执行此操作。

您可以使用 theamer 模块 告诉您要使用哪些模板文件,我猜有一些与 ubercart 一起提供,您可以覆盖它。 查看信息的候选模板部分

最后您可以使用 hook_nodeapi op=view 控制实际进入页面并在 $body 变量中显示的内容。

If the issue is purely style you can write your own CSS to do this.

You can use the theamer module to tell you which template files to use, I would guess that there are some which come with ubercart which you can override. Look in the candidate template section of the info

Finally you can use hook_nodeapi op=view to control what actually gets onto the page to display in the $body variable.

诗酒趁年少 2024-07-28 07:30:41

您需要查看位于以下路径下的模板:

./sites/all/modules/ubercart/uc_product/views

这将是一个开始。 这就是节点可能构建的地方。

You'll want to look at the templates which will be under a path like:

./sites/all/modules/ubercart/uc_product/views

That will be a start. That's where the node is likely built.

我的奇迹 2024-07-28 07:30:41

如果您使用 Devel 模块,您可以看到数组和对象的确切结构,并从 $node 对象中准确获取您需要的内容。 然后创建一个 node-product.tpl.php 文件,并将 $content 变量替换为这些部分。 这些变量值中的大多数都具有完整的标记。

如果要更改属性(例如属性)的标记,则需要更改处理属性 div 的预处理函数。 如果你只是从开头和结尾删除 id="attributes" (也许是类?我忘了)div,它们都会在自己的 class="attribute" 包装器中单独打印。 只需将其添加到您的 template.php 文件中即可。

然后,您可以使用 CSS 将它们移动到整个页面,而不是将它们全部困在一个 div 中。

您还可以使用上面打印单独页面变量的方法来移动标记中的不同元素。

其中很多工作都可以使用纯 CSS 来完成,但是当 CSS 在不良浏览器中错误显示时,拥有不会中断的标记是件好事。

希望这有帮助。 我不确定所有这些是否都能在 Drupal 5 中工作,因为我是用 6 来做这一切的……所以希望如此。

If you use the Devel module, you can see the exact structure of the arrays and objects, and grab exactly what you need from the $node object. then make a node-product.tpl.php file, and replace the $content variable with those parts. Most of those variable values have the markup intact.

If you want to change the markup for, say, the attributes, you need to change the preprocess function that processes the attribute div. If you just drop the id="attributes" (class maybe? i forget) div from the beginning and end, they'll all print individually in their own class="attribute" wrapper. Just add that to your template.php file.

You can then move them all over the page with CSS, instead of having them all trapped in one div.

You can also use the method above of printing the separate page variables to move the different elements around in the markup.

A lot of that can be done with pure CSS, but it's nice to have markup that doesn't break when CSS mis-displays in bad browsers.

Hope this is helpful. I'm not sure if all of this will work in Drupal 5, since I was doing all of this with 6... so hopefully.

噩梦成真你也成魔 2024-07-28 07:30:41

下面是 Jeremy French 提到的使用 hook_nodeapi 的示例:

/**
 * Implements hook_nodeapi().
 */
function YOUR_MODULE_nodeapi(&$node, $op, $arg3 = NULL, $arg4 = NULL) {
  switch ($op) {
    case 'view':
    // Don't show list price unless set.
    if (isset($node->content['list_price']) && $node->list_price == 0) {
      unset($node->content['list_price']);
    }
    break;
  }
}

查看modules/ubercart/uc_product/uc_product.module 中的 uc_product_view() 以查看各种内容字段。

Here's an example of using hook_nodeapi as mentioned by Jeremy French:

/**
 * Implements hook_nodeapi().
 */
function YOUR_MODULE_nodeapi(&$node, $op, $arg3 = NULL, $arg4 = NULL) {
  switch ($op) {
    case 'view':
    // Don't show list price unless set.
    if (isset($node->content['list_price']) && $node->list_price == 0) {
      unset($node->content['list_price']);
    }
    break;
  }
}

Look in uc_product_view() in modules/ubercart/uc_product/uc_product.module to see the various content fields.

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