21 Replies Latest reply on Aug 3, 2007 5:23 PM by Newsgroup_User

    PHP Includes - Simple Txt File

    destind4film
      I have been playing around with using the PHP includes/require for filling in the content of a page. This would be very useful for any pages where the content changes often or from eternal sources since I could upload txt files with the same name to a folder and overwrite the existing ones.

      The problem in my testing of this is that the text gets propogated in the content area a single huge block with no paragraph separations. The original txt file has several separate paragraphs but that is not the output seen in the design view or browser. I have checked my CSS as well for the main content area and all I have set are my font styles, margins and padding.

      Does anyone know if there is something else I need to do to fix this using either CSS or PHP?

      Thanks.
        • 1. Re: PHP Includes - Simple Txt File
          bregent Most Valuable Participant
          >The original txt file has several separate paragraphs

          What type of paragraph marks? If it's not html <p>, then the browser won't treat it as such.
          • 2. Re: PHP Includes - Simple Txt File
            Level 7
            destind4film wrote:
            > I have been playing around with using the PHP includes/require for filling in
            > the content of a page. This would be very useful for any pages where the
            > content changes often or from eternal sources since I could upload txt files
            > with the same name to a folder and overwrite the existing ones.
            >
            > The problem in my testing of this is that the text gets propogated in the
            > content area a single huge block with no paragraph separations. The original
            > txt file has several separate paragraphs but that is not the output seen in the
            > design view or browser.

            The output is always html, even if your file is a txt file. So in html you have to use <p></p> for
            paragraphs or <br> for line breaks.

            > I have checked my CSS as well for the main content
            > area and all I have set are my font styles, margins and padding.
            >
            > Does anyone know if there is something else I need to do to fix this using
            > either CSS or PHP?

            You can either enter html formatting tags in the text file, to create paragraphs and line breaks, or
            you can replace the line breaks in the text file with br tags and output the results instead of just
            including the file, as such:

            <?php
            $text = file_get_contents('url/to/your/textfile.txt');
            $new_text = str_replace(array("\n","\r","\r\n"),'<br>',$text);
            echo $new_text;
            ?>

            >
            > Thanks.
            >


            --
            seb ( ---@webtrans1.com)
            http://webtrans1.com | high-end web design

            An Ingenious WebSite Builder: http://sitelander.com
            • 3. PHP Includes - Simple Txt File
              destind4film Level 1
              entering the <p> tags works when using just the <?php include('url/file'); ?> to grab the txt.

              Now the real question is whether or not there is a better way to automate adding <p> tags to every single paragraph. Somewhat defeats the purpose of me trying to use the includes at all.

              Anyway to automate adding those tags to a txt file???

              Otherwise, I might do just as well by copy and pasting text manually in DW.
              • 4. Re: PHP Includes - Simple Txt File
                destind4film Level 1
                Hey seb,

                can you elaborate on how this string works:

                If my txt file doesn't have manually inputted <br/> or <p> tags, does this string create them for me?

                <?php
                $text = file_get_contents('url/to/your/textfile.txt');
                $new_text = str_replace(array("\n","\r","\r\n"),'<br>',$text);
                echo $new_text;
                ?>
                • 5. PHP Includes - Simple Txt File
                  destind4film Level 1
                  I guess this is not entirely OT, but another issue I am noticing with the includes is that my CSS doesn't seem to be applying to the text at all. I had specified 10px padding/margins and the text is filling entirely to the left and right of the column with no border or padding...

                  My code is as follows:
                  • 6. Re: PHP Includes - Simple Txt File
                    Level 7
                    No. The entirety of the text file will be inserted in the page to replace
                    the include directive.

                    --
                    Murray --- ICQ 71997575
                    Adobe Community Expert
                    (If you *MUST* email me, don't LAUGH when you do so!)
                    ==================
                    http://www.dreamweavermx-templates.com - Template Triage!
                    http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
                    http://www.dwfaq.com - DW FAQs, Tutorials & Resources
                    http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
                    ==================


                    "destind4film" <webforumsuser@macromedia.com> wrote in message
                    news:f8vu95$o30$1@forums.macromedia.com...
                    > Hey seb,
                    >
                    > can you elaborate on how this string works:
                    >
                    > If my txt file doesn't have manually inputted <br/> or <p> tags, does this
                    > string create them for me?
                    >
                    > <?php
                    > $text = file_get_contents('url/to/your/textfile.txt');
                    > $new_text = str_replace(array("\n","\r","\r\n"),'<br>',$text);
                    > echo $new_text;
                    > ?>
                    >
                    >


                    • 7. Re: PHP Includes - Simple Txt File
                      Level 7
                      Are you referring to what you see when looking at the INCLUDE file, or the
                      PARENT FILE?

                      --
                      Murray --- ICQ 71997575
                      Adobe Community Expert
                      (If you *MUST* email me, don't LAUGH when you do so!)
                      ==================
                      http://www.dreamweavermx-templates.com - Template Triage!
                      http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
                      http://www.dwfaq.com - DW FAQs, Tutorials & Resources
                      http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
                      ==================


                      "destind4film" <webforumsuser@macromedia.com> wrote in message
                      news:f90355$a8$1@forums.macromedia.com...
                      >I guess this is not entirely OT, but another issue I am noticing with the
                      > includes is that my CSS doesn't seem to be applying to the text at all. I
                      > had
                      > specified 10px padding/margins and the text is filling entirely to the
                      > left and
                      > right of the column with no border or padding...
                      >
                      > My code is as follows:
                      >
                      > <p class="content"><?php include('letters/letter.txt'); ?>
                      >


                      • 8. Re: PHP Includes - Simple Txt File
                        Level 7
                        Two ways come to mind:

                        1. Copy the text file into a new blank DW page, delete the top and bottom
                        <head> and <body> tag stuff, then save it.

                        or

                        2. If you're working with MS Word, you can search for paragraph marks (^p)
                        and replace them with the tags (</p><p>). You may be able to do the same
                        thing with your word processor or text editor if you don't use Word.

                        MD


                        destind4film wrote:
                        > Yeah that worked!
                        >
                        > Now the real question is whether or not there is a better way to
                        > automate adding <p> tags to every single paragraph. Somewhat
                        > defeats the purpose of me trying to use the includes at all.
                        >
                        > Anyway to automate adding those tags to a txt file???
                        >
                        > Otherwise, I might do just as well by copy and pasting text manually
                        > in DW.


                        • 9. Re: PHP Includes - Simple Txt File
                          destind4film Level 1
                          Not sure what you mean by include file vs. parent file...

                          quote:

                          Originally posted by: Newsgroup User
                          Are you referring to what you see when looking at the INCLUDE file, or the
                          PARENT FILE?

                          --
                          Murray --- ICQ 71997575
                          Adobe Community Expert
                          (If you *MUST* email me, don't LAUGH when you do so!)
                          ==================
                          http://www.dreamweavermx-templates.com - Template Triage!
                          http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
                          http://www.dwfaq.com - DW FAQs, Tutorials & Resources
                          http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
                          ==================


                          "destind4film" <webforumsuser@macromedia.com> wrote in message
                          news:f90355$a8$1@forums.macromedia.com...
                          >I guess this is not entirely OT, but another issue I am noticing with the
                          > includes is that my CSS doesn't seem to be applying to the text at all. I
                          > had
                          > specified 10px padding/margins and the text is filling entirely to the
                          > left and
                          > right of the column with no border or padding...
                          >
                          > My code is as follows:
                          >
                          > <p class="content"><?php include('letters/letter.txt'); ?>
                          >





                          • 10. Re: PHP Includes - Simple Txt File
                            Level 7
                            The Include file is what you're calling the txt file. The Parent is the file
                            that CALLS the Include file.


                            destind4film wrote:
                            > Not sure what you mean by include file vs. parent file...
                            >
                            >
                            quote:

                            Originally posted by: Newsgroup User
                            > Are you referring to what you see when looking at the INCLUDE file,
                            > or the PARENT FILE?
                            >
                            >
                            > "destind4film" <webforumsuser@macromedia.com> wrote in message
                            > news:f90355$a8$1@forums.macromedia.com...
                            >> I guess this is not entirely OT, but another issue I am noticing
                            >> with the includes is that my CSS doesn't seem to be applying to the
                            >> text at all. I had
                            >> specified 10px padding/margins and the text is filling entirely to
                            >> the left and
                            >> right of the column with no border or padding...
                            >>
                            >> My code is as follows:
                            >>
                            >> <p class="content"><?php include('letters/letter.txt'); ?>
                            >>
                            >
                            >
                            >



                            • 11. Re: PHP Includes - Simple Txt File
                              Level 7
                              Sorry. I was channeling Murray for a second there.

                              destind4film wrote:
                              > Not sure what you mean by include file vs. parent file...
                              >
                              >
                              quote:

                              Originally posted by: Newsgroup User
                              > Are you referring to what you see when looking at the INCLUDE file,
                              > or the PARENT FILE?
                              >
                              >
                              > "destind4film" <webforumsuser@macromedia.com> wrote in message
                              > news:f90355$a8$1@forums.macromedia.com...
                              >> I guess this is not entirely OT, but another issue I am noticing
                              >> with the includes is that my CSS doesn't seem to be applying to the
                              >> text at all. I had
                              >> specified 10px padding/margins and the text is filling entirely to
                              >> the left and
                              >> right of the column with no border or padding...
                              >>
                              >> My code is as follows:
                              >>
                              >> <p class="content"><?php include('letters/letter.txt'); ?>
                              >>
                              >
                              >
                              >



                              • 12. Re: PHP Includes - Simple Txt File
                                destind4film Level 1
                                ok, well the include file is just a txt. But the CSS that I am trying to apply is being called in the p tags surrounding the php statement...if that makes sense...

                                In any case...the include does not apply the CSS style that it should. This is apparent looking at the page in design view or in the browser...

                                does that clarify?
                                • 13. Re: PHP Includes - Simple Txt File
                                  Level 7
                                  Try surrounding the include call with a div and give the div that class.
                                  Without seeing the page it's hard to say, but I suspect the <p> class is
                                  being "cancelled" with the first </p> tag in the include file.



                                  destind4film wrote:
                                  > ok, well the include file is just a txt. But the CSS that I am
                                  > trying to apply is being called in the p tags surrounding the php
                                  > statement...if that makes sense...
                                  >
                                  > In any case...the include does not apply the CSS style that it
                                  > should. This is apparent looking at the page in design view or in
                                  > the browser...
                                  >
                                  > does that clarify?


                                  • 14. Re: PHP Includes - Simple Txt File
                                    Level 7
                                    Good job. The hair's wrong though...

                                    --
                                    Murray --- ICQ 71997575
                                    Adobe Community Expert
                                    (If you *MUST* email me, don't LAUGH when you do so!)
                                    ==================
                                    http://www.dreamweavermx-templates.com - Template Triage!
                                    http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
                                    http://www.dwfaq.com - DW FAQs, Tutorials & Resources
                                    http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
                                    ==================


                                    "Mad Dog" <md@maddogproductions-remove.com> wrote in message
                                    news:f907aj$4u2$1@forums.macromedia.com...
                                    > Sorry. I was channeling Murray for a second there.
                                    >
                                    > destind4film wrote:
                                    >> Not sure what you mean by include file vs. parent file...
                                    >>
                                    >>
                                    quote:

                                    Originally posted by: Newsgroup User
                                    >> Are you referring to what you see when looking at the INCLUDE file,
                                    >> or the PARENT FILE?
                                    >>
                                    >>
                                    >> "destind4film" <webforumsuser@macromedia.com> wrote in message
                                    >> news:f90355$a8$1@forums.macromedia.com...
                                    >>> I guess this is not entirely OT, but another issue I am noticing
                                    >>> with the includes is that my CSS doesn't seem to be applying to the
                                    >>> text at all. I had
                                    >>> specified 10px padding/margins and the text is filling entirely to
                                    >>> the left and
                                    >>> right of the column with no border or padding...
                                    >>>
                                    >>> My code is as follows:
                                    >>>
                                    >>> <p class="content"><?php include('letters/letter.txt'); ?>
                                    >>>
                                    >>
                                    >>
                                    >>

                                    >
                                    >


                                    • 15. Re: PHP Includes - Simple Txt File
                                      Level 7
                                      Damn. I keep hoping I'll get more nose and ear hair but so far it just
                                      hasn't happened...

                                      Murray *ACE* wrote:
                                      > Good job. The hair's wrong though...
                                      >
                                      >
                                      > "Mad Dog" <md@maddogproductions-remove.com> wrote in message
                                      > news:f907aj$4u2$1@forums.macromedia.com...
                                      >> Sorry. I was channeling Murray for a second there.
                                      >>
                                      >> destind4film wrote:
                                      >>> Not sure what you mean by include file vs. parent file...
                                      >>>
                                      >>>
                                      quote:

                                      Originally posted by: Newsgroup User
                                      >>> Are you referring to what you see when looking at the INCLUDE file,
                                      >>> or the PARENT FILE?
                                      >>>
                                      >>>
                                      >>> "destind4film" <webforumsuser@macromedia.com> wrote in message
                                      >>> news:f90355$a8$1@forums.macromedia.com...
                                      >>>> I guess this is not entirely OT, but another issue I am noticing
                                      >>>> with the includes is that my CSS doesn't seem to be applying to the
                                      >>>> text at all. I had
                                      >>>> specified 10px padding/margins and the text is filling entirely to
                                      >>>> the left and
                                      >>>> right of the column with no border or padding...
                                      >>>>
                                      >>>> My code is as follows:
                                      >>>>
                                      >>>> <p class="content"><?php include('letters/letter.txt'); ?>
                                      >>>>
                                      >>>
                                      >>>
                                      >>>



                                      • 16. Re: PHP Includes - Simple Txt File
                                        destind4film Level 1
                                        That was awesome! I really need to start learning how to use divs better! Looks perfect now!!!
                                        • 17. Re: PHP Includes - Simple Txt File
                                          Level 7
                                          Whoo-eee! Glad we could help. (Even if I don't have Murray's hair.)

                                          destind4film wrote:
                                          > That was awesome! I really need to start learning how to use divs
                                          > better! Looks perfect now!!!


                                          • 18. Re: PHP Includes - Simple Txt File
                                            Level 7
                                            On 03 Aug 2007 in macromedia.dreamweaver, Mad Dog wrote:

                                            > Whoo-eee! Glad we could help. (Even if I don't have Murray's hair.)

                                            It's the silver paint...

                                            --
                                            Joe Makowiec
                                            http://makowiec.net/
                                            Email: http://makowiec.net/contact.php
                                            • 19. Re: PHP Includes - Simple Txt File
                                              Level 7
                                              Joe Makowiec wrote:
                                              > On 03 Aug 2007 in macromedia.dreamweaver, Mad Dog wrote:
                                              >
                                              >> Whoo-eee! Glad we could help. (Even if I don't have Murray's hair.)
                                              >
                                              > It's the silver paint...

                                              Did it rub off on your hand?


                                              • 20. Re: PHP Includes - Simple Txt File
                                                Level 7
                                                Mad Dog wrote:
                                                > Joe Makowiec wrote:
                                                >> On 03 Aug 2007 in macromedia.dreamweaver, Mad Dog wrote:
                                                >>
                                                >>> Whoo-eee! Glad we could help. (Even if I don't have Murray's hair.)
                                                >> It's the silver paint...
                                                >
                                                > Did it rub off on your hand?
                                                >
                                                >

                                                so i leave for a few hours and come back just to ask myself "what the hell happened to this thread".....

                                                --
                                                seb ( ---@webtrans1.com)
                                                http://webtrans1.com | high-end web design

                                                An Ingenious WebSite Builder: http://sitelander.com
                                                • 21. Re: PHP Includes - Simple Txt File
                                                  Level 7
                                                  (_seb_) wrote:
                                                  > Mad Dog wrote:
                                                  >> Joe Makowiec wrote:
                                                  >>> On 03 Aug 2007 in macromedia.dreamweaver, Mad Dog wrote:
                                                  >>>
                                                  >>>> Whoo-eee! Glad we could help. (Even if I don't have Murray's hair.)
                                                  >>> It's the silver paint...
                                                  >>
                                                  >> Did it rub off on your hand?
                                                  >>
                                                  >>
                                                  >
                                                  > so i leave for a few hours and come back just to ask myself "what the
                                                  > hell happened to this thread".....

                                                  That'll teach you to leave again.