Jump to content

Donny Bahama

Members
  • Posts

    17
  • Joined

  • Last visited

Posts posted by Donny Bahama

  1. Thank you, Ingolme. Including those blocks made my test file work. But my actual files are more complicated. They're basically a full web page, divided up into chunks so I can require the header file and require the footer file so that, if I decide to make changes to the navmenu or the footer, I only have to change them in one place.

    Everything worked beautifully until I decided I wanted to mix in some php. Under those circumstances, what is the right way to do this?

  2. In the actual (not the test) files, there's a bunch of html code in part1, then I use the php open/close tags, run several commands which result in a bunch of text being assigned to a variable ($promotext) then, in part2, I try to write that string to the page (again, in the middle of a bunch of html code, so I use

    <?php echo $promotext; ?>

    but the text isn't shown on the final/main page.

  3. 28 minutes ago, iwato said:

    if you use the require( ) function, there is no need to use the open( ) function.  It is just like copying part2.php into part1.php at that point where you insert the require( ) function.

    Thank you for your response, iwato. I was only using fopen/fwrite/fread as an alternative method to try to get the variable text from one part to another (because it's just NOT working for me.

    I tried a simple test...

    Complete contents of test1.php:

    <?php
    require "part1.php";
    require "part2.php";
    require "part3.php";
    ?>

    Complete contents of part1.php:

    $city = "Danville";

    Complete contents of part2.php:

    $citydesc = "pleasant";

    Complete contents of part3.php:

    echo "$city is a $citydesc place to live.";

    When I go to test1.php in my browser, here is the full text of the page:

    Quote

    $city = "Danville";$citydesc = "pleasant";echo "$city is a $citydesc place to live.";

     

  4. Let's say I have main.php which consists of:

    <?php
    require "part1.php";
    require "part2.php";
    require "part3.php";
    ?>

    If I define/set a variable in part1.php (i.e. $city = "Danville"; ), shouldn't I be able to echo $city in part2.php ?

    If not, why not? (And what would be the appropriate workaround? I've tried using fopen/fwrite/fread but for some reason, the file isn't being written. :frustrated:)

  5. If you click on the "Services" item in my navigation menu, the nav bar gets really tall (instead of just a portion of it dropping down) and all the items in the nav menu get aligned to the bottom. It looks pretty crappy. Can anyone suggest the best/right way to correct it? Thanks for your time and consideration!

     

  6. It occurs to me that it might be a good idea to have the pages on my site be modular... Is there some way I can just include (like I would in php) a file for my banner, navigation, footer, etc. I'm currently going through and editing every file on my site - all because I decided to make a change to my nav menu. If I have to go with php pages instead, I can do that, but I thought I'd check first.

    If there is a way to do this, is it well-supported by all browsers (even old ones/IE/etc.)? If I have to go with php pages, are there SEO issues/complications to doing so? I would assume they would only look at the rendered pages, right?

  7. I'm using a script that toggles different popup divs when different links are clicked. The problem is the placement of the popup with regard to the screen height. I always want the popups centered horizontally so each popup has margin-left and margin-right set to auto -- but setting margin-top and margin-bottom to auto doesn't work. Is there some way to position the popups at the top of the visible screen so that even if it's viewed on a relatively small screen (i.e. a smartphone in portrait mode), the popup will still pop up in a place that's vertically appropriate, regardless of how far down the page the user has scrolled?

    The fact that position:sticky exists makes me think that there must be some way of doing this but when I try to detect where the top of a sticky background image is, I always get 0px.

  8. Here's something interesting I tried that seems like a good start. I'll document it here in case it helps anyone else...

    I broke the line of text into 4 (approx. equal length) chunks. within each chunk, I replaced the spaces with non-breaking space characters - &nbsp;, leaving actual spaces between each of the quarters. That seems to help a lot. Now I'll play with max-width and breakpoints to get it right where I want it.

  9. Say I have a wide div (100%) which contains a single line of text. If the screen is less than a certain width, the line will wrap. Depending on the width of the screen, there could be one long line of text with a single word on the second line. That looks crappy. Is there some way I can tell it to split the line in the middle if it won't fit on one line? Or in thirds if it won't fit on 2 lines? Or in fourths, etc.....

×
×
  • Create New...