SitePoint Sponsor

User Tag List

Results 1 to 21 of 21
  1. #1
    SitePoint Enthusiast
    Join Date
    Sep 2004
    Location
    Long Island, NY
    Posts
    34
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    A Way To Add Div Tags To A Whole Web?

    Is there a tool to add a set of body tags to all of the pages in my web? I just need to add a set of body tags before and after my my <p>'s.

    I am using dreamweaver. My web is roughly 200 pages so any help or advice would be welcomed!
    Last edited by mortgage-pro-seo; Nov 3, 2004 at 08:44.

  2. #2
    SitePoint Wizard silver trophybronze trophy Nadia P's Avatar
    Join Date
    Oct 2004
    Location
    NSW Australia
    Posts
    3,564
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could try a find and replace. I think this should work:

    find <body>
    replace with <div><body>

    find </body>
    replace with </body></div>

    Important Note: Please back up before you try this

    Why are you needing to do this btw?

    Nadia

  3. #3
    Non-Member c1vineoflife's Avatar
    Join Date
    Sep 2004
    Location
    CA
    Posts
    460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Nadia P
    You could try a find and replace. I think this should work:

    find <body>
    replace with <div><body>

    find </body>
    replace with </body></div>

    Important Note: Please back up before you try this

    Why are you needing to do this btw?

    Nadia
    Shouldn't it be:

    <body><div> and then </div></body>?

    Correct me if I'm wrong, but I don't think you can put div tags around the body tag (well you can, but it's either not going to do much, or not display correctly).

  4. #4
    SitePoint Wizard silver trophybronze trophy Nadia P's Avatar
    Join Date
    Oct 2004
    Location
    NSW Australia
    Posts
    3,564
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by c1vineoflife
    Shouldn't it be:

    <body><div> and then </div></body>?
    Could well be.... not exactly sure what mortgage is trying to do - hence my question to clarify..


    Correct me if I'm wrong, but I don't think you can put div tags around the body tag (well you can, but it's either not going to do much, or not display correctly).
    In which case your version would be more appropriate.

    nadia

  5. #5
    The CSS Clinic is open silver trophybronze trophy
    Paul O'B's Avatar
    Join Date
    Jan 2003
    Location
    Hampshire UK
    Posts
    40,556
    Mentioned
    183 Post(s)
    Tagged
    6 Thread(s)
    Hi,

    The serach and replace method should work as long as the pages are well structured and there are no id's or classes in the body tag to upset things.

    The divs should of course go inside the body tags as pointed out above

    However, and this is important, before you even try a sitewide search and replace (especially on 200 pages+) make you sure you back up the whole site first. Otherwise you could destroy your site in one go.

    I usually test on one page first to make sure its working but I still backup the whole site first before trying globally.

    Paul

  6. #6
    SitePoint Wizard silver trophybronze trophy Nadia P's Avatar
    Join Date
    Oct 2004
    Location
    NSW Australia
    Posts
    3,564
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    However, and this is important, before you even try a sitewide search and replace (especially on 200 pages+) make you sure you back up the whole site first. Otherwise you could destroy your site in one go.
    Definitely and why I mentioned this in my first post - I just forgot to use <b> to make it stand out .... :-)

    Nadia

  7. #7
    The CSS Clinic is open silver trophybronze trophy
    Paul O'B's Avatar
    Join Date
    Jan 2003
    Location
    Hampshire UK
    Posts
    40,556
    Mentioned
    183 Post(s)
    Tagged
    6 Thread(s)
    Quote Originally Posted by Nadia
    I just forgot to use <b> to make it stand out ....
    Sorry Nadia, my fault - I missed that - I didn't mean to repeat you

  8. #8
    SitePoint Enthusiast
    Join Date
    Sep 2004
    Location
    Long Island, NY
    Posts
    34
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I was not clear with what I ask for. I have been stripping my pages down to nothing but <p>paragraphs</p>.

    I plan to create a template for all the pages. In order to get the pages into a dwt I need to surround <p> tags which I already have with a <body> tag. I donít think I can use the find-and-replace to do that.

    Is there a way to surround the <p> tags which I already with a <body> tags?

    Is there a tool which allows me to add this code to my pages?

  9. #9
    Non-Member c1vineoflife's Avatar
    Join Date
    Sep 2004
    Location
    CA
    Posts
    460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by mortgage-pro-seo
    I was not clear with what I ask for. I have been stripping my pages down to nothing but <p>paragraphs</p>.

    I plan to create a template for all the pages. In order to get the pages into a dwt I need to surround <p> tags which I already have with a <body> tag. I donít think I can use the find-and-replace to do that.

    Is there a way to surround the <p> tags which I already with a <body> tags?

    Is there a tool which allows me to add this code to my pages?
    This is very confusing. Can I take a look at the full code you have for one of your pages?

  10. #10
    SitePoint Enthusiast
    Join Date
    Sep 2004
    Location
    Long Island, NY
    Posts
    34
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <p>Mortgagesaver provides the best mortgage solutions when you refinance, purchase
    a home, rehab a home with hard money, credit repair, foreclosure forbearance,
    and when you cash out refinance.</p>
    <p>Before you embark on a program to refinance your home, there are a few mortgage
    refinance questions you will need to answer. Once you address these questions
    you will be able to make the best financial decision.</p>
    <p>Please contact the real estate transaction engineer today. We will work with
    you to ensure you acquire the best mortgage for your situation.</p>
    <p>We can organize everything by telephone for a quick hassle free real estate
    closing.</p>

    This is my code. I am simply trying to get body tags to go around this. Is there a way to accomplish this via a batch process?

  11. #11
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Yes, with XSLT:
    HTML Code:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="html" version="4.01" 
    doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"
    doctype-system="http://www.w3.org/TR/html4/loose.dtd"/>
    <xsl:template match="/">
    <html>
      <head>
      <title>Whatever</title>
      <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
      </head>
      <body>
      <div>
      <xsl:apply-templates/>
      </div>
      </body>
    </html>
    </xsl:template>
    <xsl:template match="p">
      <p><xsl:apply-templates/></p>
    </xsl:template>
    </xsl:stylesheet>
    Of course, this assumes that your paragraphs are well-formed in an XML sense (i.e. all tags are closed). The XSL stylesheet above will leave you with a valid HTML 4.01 Transitional document.

  12. #12
    The CSS Clinic is open silver trophybronze trophy
    Paul O'B's Avatar
    Join Date
    Jan 2003
    Location
    Hampshire UK
    Posts
    40,556
    Mentioned
    183 Post(s)
    Tagged
    6 Thread(s)
    We'd need to see the whole structure of the page to see if theres anything you can use to do a search and replace with consistently.

    If that code was the same on all pages then you could simply replace it with code that has body tags around etc but of course that code isn't the same on all pages is it?

    This also begs another question as to why your page has no body tags in the first place - what have you got there instead ? Have you got head tags? html tags?

    You'll have to show us a complete page (or two) before any of us are any the wiser

    Paul
    Edit:


    Ignore the above as Vinnie has come to your rescue

  13. #13
    Non-Member c1vineoflife's Avatar
    Join Date
    Sep 2004
    Location
    CA
    Posts
    460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by vgarcia
    Yes, with XSLT:
    HTML Code:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="html" version="4.01" 
    doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"
    doctype-system="http://www.w3.org/TR/html4/loose.dtd"/>
    <xsl:template match="/">
    <html>
      <head>
      <title>Whatever</title>
      <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
      </head>
      <body>
      <div>
      <xsl:apply-templates/>
      </div>
      </body>
    </html>
    </xsl:template>
    <xsl:template match="p">
      <p><xsl:apply-templates/></p>
    </xsl:template>
    </xsl:stylesheet>
    Of course, this assumes that your paragraphs are well-formed in an XML sense (i.e. all tags are closed). The XSL stylesheet above will leave you with a valid HTML 4.01 Transitional document.

    How exactly would one use this? And what does it do?

  14. #14
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by c1vineoflife
    How exactly would one use this? And what does it do?
    http://www.w3schools.com/xsl/ and http://old.alistapart.com/stories/xslt/ can explain it a million times better than I would.

  15. #15
    SitePoint Enthusiast
    Join Date
    Sep 2004
    Location
    Long Island, NY
    Posts
    34
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That is the how my code looks for every page. I was asking if if it was possible for me to add body tags? I don't see how the find-and-replace could work?

  16. #16
    The CSS Clinic is open silver trophybronze trophy
    Paul O'B's Avatar
    Join Date
    Jan 2003
    Location
    Hampshire UK
    Posts
    40,556
    Mentioned
    183 Post(s)
    Tagged
    6 Thread(s)
    Hi,
    That is the how my code looks for every page. I was asking if if it was possible for me to add body tags? I don't see how the find-and-replace could work?
    Well Vinnie has given you a solution above but if your code is the same on every page as you say then simply do this.

    From the DW find and replace menu:

    Find:
    Code:
    <p>Mortgagesaver provides the best mortgage solutions when you refinance, purchase
    a home, rehab a home with hard money, credit repair, foreclosure forbearance,
    and when you cash out refinance.</p>
    <p>Before you embark on a program to refinance your home, there are a few mortgage
    refinance questions you will need to answer. Once you address these questions
    you will be able to make the best financial decision.</p>
    <p>Please contact the real estate transaction engineer today. We will work with
    you to ensure you acquire the best mortgage for your situation.</p>
    <p>We can organize everything by telephone for a quick hassle free real estate
    closing.</p>

    Replace:
    Code:
    <body>
    <p>Mortgagesaver provides the best mortgage solutions when you refinance, purchase
    a home, rehab a home with hard money, credit repair, foreclosure forbearance,
    and when you cash out refinance.</p>
    <p>Before you embark on a program to refinance your home, there are a few mortgage
    refinance questions you will need to answer. Once you address these questions
    you will be able to make the best financial decision.</p>
    <p>Please contact the real estate transaction engineer today. We will work with
    you to ensure you acquire the best mortgage for your situation.</p>
    <p>We can organize everything by telephone for a quick hassle free real estate
    closing.</p> 
    </body>
    Paul

  17. #17
    SitePoint Enthusiast
    Join Date
    Sep 2004
    Location
    Long Island, NY
    Posts
    34
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Would I still have to do this for every page?

    If so, than that is really not a time saving solution.

  18. #18
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by mortgage-pro-seo
    Would I still have to do this for every page?

    If so, than that is really not a time saving solution.
    You can create a batchfile that will take every html file in a directory and apply the XSL to it. That would be a timesaver.

  19. #19
    The CSS Clinic is open silver trophybronze trophy
    Paul O'B's Avatar
    Join Date
    Jan 2003
    Location
    Hampshire UK
    Posts
    40,556
    Mentioned
    183 Post(s)
    Tagged
    6 Thread(s)
    Would I still have to do this for every page?

    If so, than that is really not a time saving solution
    If that response was directed to thh search and replace option rather than Vinnies solution then simply in DW you would select entire site from the dropdown of the find and replace menu and DW would find and replace everything in the whole site with one mouse click.

    As I said before Use with Care.

    Paul

  20. #20
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by Paul O'B
    As I said before Use with Care.
    Yeah, sitewide search and replace is some serious voodoo

  21. #21
    SitePoint Enthusiast
    Join Date
    Sep 2004
    Location
    Long Island, NY
    Posts
    34
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have found a gem. The dreamweaver tidy extension can do exactly what I was looking for and much more.

    It will even clean up your code so it will validate via xhtml.

    Enjoy!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •