开发者

DRUPAL, Views module: can I dynamically change the number of columns of my grid?

I'm using drupal for a website and I've created a gri开发者_如何学JAVAd with the View module to display my nodes.

Can I dynamically change the number of columns of my grid with javascript according to the browser width ?

At the moment I can only specify it in the back-end.

thanks


Why bother with the extra overhead, and it'll break if they disable javascript? We had this same problem with displaying employee pics.

Rather than the view display style grid, use the view display style Unformatted. Then in firefox use the firebug plugin to inspect the div containing your content and add a float:left; style for that.

Example:

div#content div.view-display-id-page_4 div.views-row { 
 float: left; // floats left so they fit the space
 margin: 0 20px 20px 0; // gives them breathing room
 position: relative;
 width: 150px; // or whatever you need for your content
 height: 250px; // or whatever you need, prevents 'stacking' elements
}

It flows with the browser width, and there's no extra overhead.


I've solved with this wonderful jquery plugin: http://welcome.totheinter.net/columnizer-jquery-plugin/


You can rewrite the DOM as much as you like with javescript. You can do almost anything with JavaScript. Detecting browsers can be a bit tricky though, but this is not related to Drupal or the Views module.


I was just looking into this myself - I believe this does what you want: http://drupalcontrib.org/api/function/cck_gallery_preprocess_node/6

Nevermind, I see you want to do it via JS, not PHP.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜