1

I have 10 images that I want to rotate within a views consisting of 6 viewable slots (my Views results). I want to rotate the 10 images so that each recieves (approx.) an equal number of views. The Node Statistics option added as a Sort Criteria does not work for this because you have to actually open and view the node itself for the counter to increment. What I want is for the counter to increment each time the images are shown from within the view.

1

IMHO I don't think that you will be able to find a module that does this. You will need to write custom code for that. Depending on how comfortable you are hacking with Drupal and PHP you might find it trivial or very difficult.

So here are the requirements:

  • The counter must persist between page renders, so you need to store it in the database. A CCK field (D6) or "just" field (D7) will do the trick. You would assign this new field to your image content type.
  • This is a View. So how could you write to CCK field when rendering a View? The answer to that is preprocessors. How to write preprocessors is beyond the scope of your question. So is how to write to a CCK field. You can look for that answer in other Stack Exchange questions and the main Drupal site.
  • On your View, you would then sort the images by this "counter field".

That should do it.

  • Thanks for the help. This sounds interesting but unfortunately I think that this is beyond the scope of my ability. Im willing to pay somebody to create this for me. If anybody is interested please get in touch. – Adrian Dec 15 '11 at 14:51
0

You can get your first part of displaying 6 of your 10 pictures an approx. equal amount of time by limiting the display to 6 and sorting them with GLOBAL RANDOM. That will just randomize the order and pick the first 6.

To your second part, that will require a lot more work, but could be done in a views theme template and a whole bunch of nodeapi()ing where each time a picture is displayed, a field is autoincremented and resaved back to the node.

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.