0

I have created a content item in Drupal 7 which has multiple image fields (well it has an image field that accepts multiple images).

When I display the item, the images are displayed one under the other, or I can put them into a lightbox gallery.

How can I change or over-ride the CSS and JavaScript code associated with these content items? Additionally, I eventually want to be able to count up the number of images in the content item and write some js to do this. But I am not sure how to find the names of the items and/or if that is indeed necessary.

My goal is to make a gallery of images that can be flicked through like many JavaScript galleries that place content in hidden tags.

1

You can use javascript to add css to your page after all the other css files have been listed.

<?php
  drupal_add_js();

  // Then in the js file you can add the css file

If you are still stuck then place a link here of your site and contact me.

0

Create a template for the node type. If your content type is called 'gallery', create a template called 'node--gallery.tpl.php'

In it define your teasers (displayed on the view gallery page) using

 <?php if (!$page): 
  // code goes here for teaser display
  // for example add a thumbnail of the first image, 
  // the title of the gallery, the amount of images in it
  // add your own classes and divs etc ...
 <?php endif; ?>

Then define the page layout...

   <?php if ($page): ?>
     // here display the actual gallery
     // alternatively you can simply avoid showing the page
     // if you enable a lightbox style slideshow gallery on the first teaser view image
     // then it would degrade nicely if javascriopt was disabled to show this page
    <?php endif; ?>      

to find the available fields you can print in the template, use

    print_r($node);

or

    <?php
       drupal_set_message(dprint_r($node, TRUE));
     ?>
0

When you use Drupal try to use what available in Drupal.

You always can use views module to manipulate content and output it in the shape you want, if you want more customization than what Views provide you (which I believe you can achieve what you want using views and lightbox module) you can use with that Custom formatters which let you control on the output of the field and you can use it with views or directly in content field format if you don't want to use views

-1
// used to add your own stylesheet
drupal_add_css();
// used to add your own script
drupal_add_js();

then you can catch all your image fiels with something like this:

 jQuery(document).ready(function() {
     jQuery('.your-image-class').hide();
 });

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.