Jump to content

Archived

This topic is now archived and is closed to further replies.

henriksteen

A smart sidebar - an idea/thought/challenge?

Recommended Posts

Hello. Pardon my english, it's bad (i'm a norwegian) and my PHP-skills are even worse, and I admit that i have not read every 7614 topics to see if this already is covered somewhere, but I got this idea/thought/question (when I started reading PHP this holiday!) of a solution I think very many would love.

So, maybe this is a challenge for you clever PHP-freaks or maybe it's elementary for all I would know; is there a simple code/script/solution for this scenario: In the web there is a "sidebar"-folder that holds a collection of small "includes", sidebar1.inc sidebar2.inc sidebar3.inc etc. etc., each one are simple text/markup of two, five or ten lines, maybe a small picture.

If the web-page called for is very short, the page/code will include one or two elements (sidebar1.inc, sidebar2.inc..). If the web-page is a longer article, the code would somehow "see" the length and add more sidebar-elements (...sidebar3 .. " 4 " 5 - .. sidebar7.inc etc.) as long as it's space in the sidebar...!? Of course, not 100% precise. But you grasp the idea?

Well, I go back to page 44 in the PHP-bible and read on (I'm slow, but I try!), and then I return here with great excitement in a couple of days...

Sincerely,
Henrik, Oslo, Norway

Share this post


Link to post
Share on other sites
[!--quoteo(post=365085:date=Apr 15 2006, 03:41 PM:name=Henrik Steen)--][div class=\'quotetop\']QUOTE(Henrik Steen @ Apr 15 2006, 03:41 PM) [snapback]365085[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Hello. Pardon my english, it's bad (i'm a norwegian) and my PHP-skills are even worse, and I admit that i have not read every 7614 topics to see if this already is covered somewhere, but I got this idea/thought/question (when I started reading PHP this holiday!) of a solution I think very many would love.

So, maybe this is a challenge for you clever PHP-freaks or maybe it's elementary for all I would know; is there a simple code/script/solution for this scenario: In the web there is a "sidebar"-folder that holds a collection of small "includes", sidebar1.inc sidebar2.inc sidebar3.inc etc. etc., each one are simple text/markup of two, five or ten lines, maybe a small picture.

If the web-page called for is very short, the page/code will include one or two elements (sidebar1.inc, sidebar2.inc..). If the web-page is a longer article, the code would somehow "see" the length and add more sidebar-elements (...sidebar3 .. " 4 " 5 - .. sidebar7.inc etc.) as long as it's space in the sidebar...!? Of course, not 100% precise. But you grasp the idea?

Well, I go back to page 44 in the PHP-bible and read on (I'm slow, but I try!), and then I return here with great excitement in a couple of days...

Sincerely,
Henrik, Oslo, Norway
[/quote]

hmmm. apart from using php to 'guess' based on a function that could count the approx number of lines in an article, the only way to get this accurate is via javascript (as you can read table/div heights after they have been drawn/show all the sitebars and hide the unncessary ones, etc).
the easiest way IMO would be to have a function to make an estimate of how many lines an article takes, and then go from there.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.