Hello,

I'm using 4.5.2 to put together a site that has an online store. The most efficient way that I found of entering products was to use the image module to batch-import all the product shots, and then adding product info to them.

I've extensively hacked my phptemplate theme to do the majority of what I need, but I am having trouble separating the image from the description - it's all output in $content.

Currently, the image comes first, and the description immediately after. What I am after is a way to do something like:

  <div class="image">
    <?php print $image ?>
  </div>
  <div class="description">
    <?php print $description ?>
  </div>

I've read the docs at drupaldocs.org, and done research for a couple weeks on how nodes are assembled, but I still need some help.

Any pointers are appreciated.

Thanks,

- Gustavo

Comments

Dublin Drupaller’s picture

Hi Gustavo...

if you're using a phptemplate theme...it should be fairly simple to do what you want...

Worth chevking the image/ module folder..I seem to remember it had a image.tpl.php file with it.

If it doesn't, the phptemplate handbook pages explains how to create your own custom layouts.

DUBLIN DRUPALLER
___________________________________________________
A drupal user by chance and a dubliner by sheer luck.
Using Drupal to help build Artist & Band web communities.

Currently in Switzerland working as an Application Developer with UBS Investment Bank...using Drupal 7 and lots of swiss chocolate

audioel’s picture

Hi,

Thanks for the reply. I am pretty familiar with how phptemplate works - but I think where I actually need to make my changes is at a higher level. There is no image.tpl.php in the image module. If you have something like that, I'd love to see it. :)

I need to modify the mechanism that creates $content, so that I can output 2 separate elements as in my example above.

I think what I'm looking at is in image_view(), inside the image.module, but I'm not sure.

Thanks,

- Gustavo

stevew’s picture

Good timing! I was just working on this last week to figure out how to take some of my flexinode output and change it into icons.

This is a quick and dirty hack you can use in a PHPTemplate theme. It involves modifying the node.tpl.php file. The way I've done it, it will only work if you want the node to be modified the same way every time. I did it because I wanted a small flexinode field to be replaced by a small image.

Right now, your node.tpl.php file has a line in it that looks something like this:

<?php print $content ?>

Just before that goes out, you can mess with the content all you want, like this:

<?php  $content=str_replace('target for replacement','new and better stuff',$content);?>

There's no reason not to make that part as complicated as you need it to be:

<?php  if ($node->thing == other_thing) {$content=str_replace('Old and Busted','New Hotness, including lots of div tags and class ids',$content);}?>

One advantage to doing it this way is that since it is in your theme, you can update your modules without having to integrate every single change all over again.

Hope this helps. Happy hacking!

Steve
--
http://theme.etmeli.us/ - Drupal themes
http://etmeli.us/ - photos, commentary, occasional sarcasm

audioel’s picture

Hi Steve,

Thanks for your reply - much appreciate it. It actually is useful for a different issue. However, I still need to figure out where I can modify the contents of $content before it's passed to phptemplate.

The solution above would not work because I'm not trying to replace fixed elements - I'm trying to separate the image from the description into 2 different variables.

Thanks,

- Gustavo

audioel’s picture

I've been hacking into the image module. So I found where $node->teaser and $node->body have image URLs concatenated onto themselves. Once there, I was able to extract individual elements by adding them to the node array, passing them to my template in phptemplate.engine, and then placing them in node.tpl.php

Dublin Drupaller’s picture

Hi Audioel..

I'm trying to do something similar, but, I'd prefer not to hack the image.module...I was thinking of having a bash at creating an image.tpl.php override file

Is that what you have more or less done, but slipped it into the node.tpl.php file ?

Any chance you could paste up an example of your node.tpl.php hack?

Cheers

Dub

DUBLIN DRUPALLER
___________________________________________________
A drupal user by chance and a dubliner by sheer luck.
Using Drupal to help build Artist & Band web communities.

Currently in Switzerland working as an Application Developer with UBS Investment Bank...using Drupal 7 and lots of swiss chocolate