View Full Version : Is it possible to determine column heights in dynamic pages?
Does anyone know if this is possible? I have a dynamic site (loads from a database). One page has content in the left column and a narrow right column containing ads. The amount of content in the left column varies depending on which record is displaying.
Is there a way to determine what the height of the left column will be right before the page is displayed so that it can be used to determine how many ads will fit in the right column? For example, if the left column is 900px in height, display 4 ads in the right column. If the left column is 1200px in height, display 5 ads in the right column.
Thanks! e :)
Snookerman
12-09-2008, 07:48 AM
I'm not sure if this is any help but you can take a look at this thread:
http://www.dynamicdrive.com/forums/showthread.php?t=39499 (http://www.dynamicdrive.com/forums/showthread.php?t=39499)
Dear snookerman: Thank you. That example is very similar in concept to what I am trying. I did go through the entire thread but couldn't find any examples of a real page to see what it looked like, so am not sure. I thought iframes were being deprecated (?). I was hoping for a simpler solution that would allow me to use code something like this:
if($leftcol_height > 600) {
include('rightcol5ad.php')
} else {
include('rightcol4ad.php)
}
I suppose I could add a field to the database record to indicate how much content there is, but that would be a maintenance nightmare. I was hoping the column height could be calculated on the fly as the page is rendered. Perhaps this is not possible.
Snookerman
12-09-2008, 03:54 PM
Yeah, of course, I agree that a php solution would be much better than inline frames, especially since we didn't get that to work in FF. If you still want to look at the working example I did have one in the thread, here is the post:
http://www.dynamicdrive.com/forums/showpost.php?p=174129&postcount=14 (http://www.dynamicdrive.com/forums/showpost.php?p=174129&postcount=14).
Like I said though, I don't do much php (not as much as I would like to), but if I stumble upon anything I'll make sure to tell you.
I downloaded the 3 files and checked it out. It's very cool what you did.
I admit to being brain-dead when it comes to Javascript, so I have no clue how I would adapt it to solve my problem. Your script seems to use the size of the external files to determine the size of the main page. My main page needs to use the size of the main column to determine which right column to use, and that can vary depending on data in a database. The page doesn't really exist until someone clicks on the link. I'm starting to think that there is no way to do this, so I am just going to forget it for now.
Thanks very much for sharing your solution. Maybe it'll suddenly dawn on me after I've had some sleep how to incorporate the logic. This happens sometimes.
Mahalo, e :)
Snookerman
12-10-2008, 12:22 PM
You're welcome, sorry I couldn't be of more assistance. Like I said, I don't use php enough (it's on my to-do list).
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.