(i had posted this in the coding forum and realized soon after that it belongs in the Newbies board better. I deleted the other post (no replies yet))

Hi all,

I'm still fairly new to PHP so please bear with me. I have a suspicion that my question has been discussed in depth numerous time, but I can't find something with forum search.

I am working on a website that uses Dreamweaver templates--I will not be the only one working on it, so using include() is out of the question, since the other people would like to use Dreamweaver.

One section of the page contains numerous pages that will need to be printed in the future. Short of manually copy pasting the pertinent code into new printer friendly html files, I thought that I could use PHP to parse out the necessary information.

My pages look something like:

<html><!-- InstanceBegin template="template.dwt" codeOutsideHTMLIsLocked="false" -->
// unwanted code and content here
<!-- InstanceBeginEditable name="Site Section" -->
// code and content I want here
<!-- InstanceEndEditable -->
// more unnecessary stuff

The comments indicate the sections of the files that I want and do not want. My idea is to insert a link in each of the pages to a php file that can parse out all of the unnecessary stuff. How would I go about doing this?

I spent some time practicing pattern matching this morning, and think that I can definitely use the <!-- InstanceBeginEditable name="Site Section" --> and <!-- InstanceEndEditable --> to my advantage.

How would I grab all of the source code from a website and turn it into a string? Is there a way that I can specify with GET in the link to the php file all the source of the html file?

I'd appreciate if anyone could advise me on what to do or point me to a previous post.

Thanks!

    Great, thanks! It worked just as I needed it to.

    For future reference, if I only need stuff in the middle of the file, is there a more efficient way of doing it other than replacing the content at the top with nothing using eregi_replace(), and repeating with the bottom?

    Or suppose I'm trying to collect data from a website. How would I approach then? Using eregi_replace() over and over would probably work, but wouldn't be that great...

      Well, if you know the specific lines you want, I'd read the file into an array using [man]file[/man], then just use the elements you need.

        Hi,

        The problem you describe is a typical layout/display problem =>
        Have a look at CSS specifications (www.w3c.org). THere is a whole section on printed media. You can decide in your layout to use tags which will only be visible in on-screen display, and when your pages is printed, it is not displayed.

        J.

          Write a Reply...