WordPress.org

Forums

Generate sidebar depending on height of post (4 posts)

  1. peek
    Member
    Posted 2 years ago #

    Hi there!

    I'm building a site which features sidebars next to each post/article displaying random thumbnails linking to other posts.
    Each sidebar should never be longer/bigger than the post it's sitting next to.
    Now of course the height of the posts vary and I want to find out/calculate the height of each post and then generate a sidebar with more or less thumbnails.

    What would be the best way to make this happen?
    Javascript??

    Best,
    p

  2. peek
    Member
    Posted 2 years ago #

    well, so far i know i can get a divs height with javascript.
    http://wordpressapi.com/2010/03/04/div-height-javascript-div-element-height-auto/
    the problem is, the moment i can do that, php is already finished generating the html and so the sidebars...

  3. WPyogi
    Forum Moderator
    Posted 2 years ago #

    Perhaps putting both the post div and the thumbnails div in another div and using overflow hidden on the thumbnails div?

  4. peek
    Member
    Posted 2 years ago #

    i thought of that too, but that would mean, i would overlap the next post...

    heres a screenshot of the design/sketch:
    http://aq295.w4yserver.at/screenshot.png

    here is a current version: http://aq295.w4yserver.at/wordpress/
    but a lot is still to be done, work in progress!

    how about getting div height, the first time php generated a post and save that value for each post. then use this value, the second time the page gets viewed, to generate the corresponding sidebar. am i crazy?

Topic Closed

This topic has been closed to new replies.

About this Topic