I need an image and TWO text elements associated with it, a "title" and a longer body of text.

I was able to hack the module to append my wysiwyg textarea description field to the caption

This should be an easy addition to the settings?

Comments

decibel.places’s picture

more info - I am using a field_collection - one image, a text field and a wysiwyg textarea

the only text field available to add is the text field for the caption

here's my hack @ line 587 of field_slideshow.module ( the last 2 lines below before the closing bracket)

      foreach ($items as $delta => $item) {
      if ($field['type'] == 'media' || $field['type'] == 'field_collection') {
        if ($field['type'] == 'media') $items[$delta]['caption'] = $items[$delta]'file']->$settings['slideshow_caption'];
        elseif ($field['type'] == 'field_collection') $items[$delta]['caption'] = $items[$delta]$settings['slideshow_caption']];
        if (!empty($items[$delta]['caption']) && isset($items[$delta]['caption'][$langcode]))
          $items[$delta]['caption'] = $items[$delta]['caption'][$langcode][0]['value'];
        else $items[$delta]['caption'] = '';
      }
      else $items[$delta]['caption'] = $item[$settings['slideshow_caption']];
      //here we add the description field to the caption
      $items[$delta]['caption'] .= $items[$delta]['field_learn_slideshow_desc']['und'][0]['value'];
    }   

so I hard coded the description field appended to the caption - works!

spesso’s picture

It's OK but you can do that in a template file insted of hacking the module.
Just copy field_slideshow.tpl.php from module directory inyo your theme directory (named exactly as it is) and you will find exactly same code inside it. You can change it there without hacking the module.

decibel.places’s picture

it's not exactly the same code in the template, but this works:

after line 15 in field_slideshow.tpl.php:

<?php if (isset($item['caption']) && $item['caption'] != '') : ?>

This adds my custom text field to the caption:

<?php $item['caption'] .= $item['field_learn_slideshow_desc']['und'][0]['value'] ?>
rerooting’s picture

So I wanted to do the same thing, but to be able to better control the formatting of the two text fields, so this adaption of #3 worked as well:

<?php if (isset($item['caption']) && $item['caption'] != '') : ?>
        <?php $item['desc'] .= $item['field_slide_desc']['und'][0]['value'] ?>
          <div class="field-slideshow-caption">
            <h3 class="field-slideshow-caption-text"><?php print $item['caption']; ?></h3>
            <div class="field-slideshow-description-text"><?php print $item['desc']; ?></div>
          </div>
<?php endif; ?>
rerooting’s picture

Actually it would seem that this solution is more appropriate, in order to hide the elements for empty fields (again, from 15):

<?php $item['desc'] .= $item['field_slide_desc']['und'][0]['value'] ?>
          <div class="field-slideshow-caption">
            <?php if (isset($item['caption']) && $item['caption'] != '') : ?>
            <h3 class="field-slideshow-caption-text"><?php print $item['caption']; ?></h3>
            <?php endif; ?>
            <?php if (isset($item['desc']) && $item['desc'] != '') : ?>
            <div class="field-slideshow-description-text"><?php print $item['desc']; ?></div>
            <?php endif; ?>
          </div>
r_gauti’s picture

#5 worked for me

thanks

rerooting’s picture

There is room for improvement, but I'm not sure where to go next.

jackbravo’s picture

Maybe adding a second caption directly to the field slideshow configuration (on node display settings)?

idflood’s picture

I'm just wondering what you think of using entity reference: #1634412: Rendering entire entity

It would be a much more flexible solution and would probably fix the issue highlighted here. On the other hand it is maybe to "heavy" ?

rerooting’s picture

idflood - love it! #1634412 is a great leap forward (for me, at least)- implementing entity reference support with a submodule for field collection is exactly what I'm looking for.

jackbravo - for the field display settings, I could definitely see that working as a base case. Whether just providing settings for a caption field, or allowing for two seperate (but optional) fields is what the maintainers intend is not something I am certain of, however a patch on this issue that provided that would probably be a way to find out!

rvallejo’s picture

Just a note here for anyone creating a custom template file, it seems that you need the file in your theme's root folder; putting it in a subfolder (ie. my theme/templates) wasn't working for me.

decibel.places’s picture

re #11

it seems that you need the file in your theme's root folder; putting it in a subfolder (ie. my theme/templates) wasn't working for me

I think it depends on your theme, where it finds the template files

capellic’s picture

Is there a better way to do this-- such as through the Manage Display screen where builders can easily add/remove fields from display?

UPDATE: Found what I'm looking for: #1634412: Rendering entire entity

lamp5’s picture

Issue summary: View changes
Status: Active » Closed (outdated)