2

I'm trying to create a slider on the front page of my template I have been working on. I have used the Views module to create a block. I have created a custom block for this view.

I am trying to make the posts in the block slide using jQuery coda. I am failing dismally. Has anyone managed to create a working posts slider for drupal 7?

| improve this question | | | | |
2

I wouldn't use views for this otherwise it s going to be more problematic to get your markup right.

Instead make a Databse query to the "node" table, grab all NID that match your node type and load them:

      $nodes = array();
      $nids = db_query('SELECT nid FROM {node} WHERE type = :type',
 array(':type' =>YOUR_NODE_TYPE))->fetchCol();
      if (!empty($nids)) {
        $nodes = node_load_multiple($nids);    
      }
      return $nodes;

Then pass these nodes to your page using a page preprocess function.

Finally override the template page for your node type: node--YOUR_NODE_TYPE.tpl.php, and there you should have your nodes available in that page (in an arbitrary variable name that your defined in the preprocess function $variables['my_bunch_of_node']=...). You just need to loop through them so that the content fits exactly the original markup required by your script.

Oh and also don't forget to add your .JS , either via the .info file, either via drupal_add_js (in the page preprocess function)

| improve this answer | | | | |
  • Thanks a lot. I have views used the views module. With it i managed to create a block. I them used jquery to animate the contents. It's working fine. It's my first drupal site and i am impresses at the progress. :) – Vezu Jul 12 '11 at 5:24
  • Good to hear, if you know JS better than drupal, that was the way to go. – silkAdmin Jul 12 '11 at 5:57

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.