Jump to content

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
Link to comment
https://forums.phpfreaks.com/topic/7481-a-smart-sidebar-an-ideathoughtchallenge/
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.
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.