okay, so first my question: i'm using this snippet to put my imagefield cck into the teaser for a content type, and it's all working well - grabs the first image and throws in teaser (in case you have ten in a field that's unlimited, this is quite useful, just grabs the first one in the series for the teaser - i did NOT write this code, it came from another site, which in turn came from yet another site where yet another person was trying to hack into this)
(from here: http://circlesandscissors.com/blog/theming-cck-imagefields-contemplate AND here: http://www.primalmedia.com/blog/building-better-drupal-photo-gallery)

...how do i get the image to present some padding? right now the text is flush with right side of image...is it my syntax? am i missing a semicolon or something?? here's the code:

- oh, also, do you think i should be using node->body (and not just the 'body' via #value)?

<div class="field field-type-image field-field-image">
  <div class="field-items" style="float:left" margin="5px 0 10px 0">
  <?php if ($node->field_mainstorypic[0]['view'] > '') : ?><?php print $node->field_mainstorypic[0]['view'] ?><?php endif; ?></div>
<?php print $node->content['body']['#value']; ?>
  </div>

...as for the opinions: per the same resource, which led to the other resource = these dudes are using a TABLE to present imagefields in rows (and absorb empty cells and so on)

you can see examples on that second link above, he's using it to build imagefield galleries - and it works sooo well, using it myself right now on a dev site!!

...but is this a good way to go? aren't tables very '97? burdensome for rendering and extensively non-compliant? thoughts? opinions?

Comments

jrglasgow’s picture

you are using the line

<div class="field-items" style="float:left" margin="5px 0 10px 0">

the way you should use the style tag

<div class="field-items" style="float:left; margin:5px 0 10px 0;">

My preferred way to do the styles would be to use a style sheet, but the above will work.

As for my opinion about floating divs as opposed to using a table:

I use divs when I can, sometimes you cannot use a div and you have to use a table, especially when using IE.

zilla’s picture

thanks - i just tried that edit, but it's still not working! and now, even more confounding, when i use the same snippet in another content type it doesn't work (event though it's working in my story type) - i believe that this latter problem is related to content using fieldgroups, but no idea why...

jrglasgow’s picture

the only difference that a field group would make is different variable names

zilla’s picture

yes, just spent some time searching on this very issue (using content template with fieldgroup tabs) -apparently it was an issue a while ago, not sure if it's entirely resolved but the variable should be present for selection, now just need to go in and see if it comes up without that odd contemplate recursion issue thing...

saltcod’s picture

not sure if htis what you're looking for, but here goes anyway:

To move the text away from the image, you have to use padding or margins, and you have to pad or margin the containing div or the image itself.

So where you have an image in a div called "imagefield" (div id="imagefield">) you need the css to be:

Either
#imagefield {padding: 10px;}

Or - to pad the image itself:
#imagefield img {padding: 10px;}

Again, sorry if this isn't what you're looking for.

Terry

zilla’s picture

@saltcod - i believe that's what i'm looking for - but i'm not sure where the div for imagefield is! the modules own css (for imagefield) is blank i believe, as it defers to the theme - but within the theme, there would appear to be no styling for imagefield, in which case i'd need a full bit of css for it, but i'm not a css person and have no idea what the 'complete' snippet looks like! i'm going to try to google imagefield styling on drupal a bit more...

also need these imagefields to lay horizontally and inline when there are several, and wrap to next line when there are many...should all be possible via css i think but not sure exactly where to begin (it applies to all content types on my site, so no need to create infinted node.tpl files, guessing it should happen in one node.tpl OR in theme's css...

saltcod’s picture

Is it not getting assigned a 'special' css class or are you just getting the generic 'field-item' class.

If the most specific element you have is the 'field-item' then you've got trouble - same as I'm having: http://drupal.org/node/325197

If you're trying to theme an imagefield called, squarethumb, for example and you've got this:

<div class="field-item"> 
<div class="squarethumb"> <img src...here.....>  </div>
</div>

Then, obviously, you can style like so:

.field-item .squarethumb {
border: 1px solid #555;
padding: 5px;
margin: 15px;

etc...

Again, hope this is even somewhere close to on target!

zilla’s picture

ah, that helps...thanks! based on your issue, sounds like this may ONLY work with contenttemplates module affecting output! sounds like a request for the imagefield module folks...the field item will have to be dynamically generated for any user madeup preset name! OR for all presets period (probably easier for basic control, though users may want different controls for different imagefields, like padding smaller on larger images etc)