Link to home
Start Free TrialLog in
Avatar of austerhaus
austerhaus

asked on

Creating DW Template to output two different versions of an html file

Hello,

I need to know if it is possible to use DW Templates to output two different versions of an HTML page from one single template interface. Basically, I need to publish content to two separate directories. One file would be a complete version with all of the content that was entered into the template (so, an entire valid HTML document). The other file, would essentially be a "stripped down" version of the complete one. The stripped version would contain basically the page's title (identified by <div id="pagetitle">) and what would be considered the "meat" of the page (everything inside <div id="maincontent">). Everything else, all the regular stuff that makes an HTML page (i.e. <html>, <head>, <body>, etc.) would be stripped. If this is possible, I would also like to know if it is something that can be user-defined. Meaning, would there be a way for the page creator to indicate whether or not a stripped version should be created?

I hope this is enough information, please let me know if there is anything else I can add.

Thank you
ASKER CERTIFIED SOLUTION
Avatar of Jason C. Levine
Jason C. Levine
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of austerhaus
austerhaus

ASKER

To clarify, the stripped version is going to be used by another group that takes the contents of the file and uses server side code to wrap it in a different "frame". Not to mean an HTML frame. They basically take my raw content slap some pretty stuff around it (menus, links, other content, etc.) and send it off to the browser. CSS was discussed as a possible solution though there were concerns regarding bandwidth and response times. We basically want to send them the smallest, most relevant file possible without the manual labor of having to really manage two unique files.
Well, as far as response time and bandwidth goes, I don't believe templates are any better than CSS for you since templates will result in two different versions of your content file.

I guess the other thing you could do is just use plain old server-side includes to call the content into the two different documents.  
See,
whatever you are developing, only HTML is delivered to client,

if you are developing a static website then you have do necessary changes to your relevant pages

or you could code your pages via help of Javascript,

or use any server side script such ASP, PHP etc.. to fullill your requirement,

in short, Dreamweaver does not have any feature to develop HTML to handle this situation,
Dreamweaver doesn't really have a method to do this. The only way I can think of getting something like this is using some kind of serverside code/javascript, which would require you knowing a bit of programming

So for ASP say you have your infopage.asp which basically consists of

<html>
<body>
<% If Request("plain") = "" Then %>
   <!--#include file ="include_files/topstuff.asp"-->
<% End If %>

Here is all my funky data!!

<% If Request("plain") = "" Then %>
   <!--#include file ="include_files/bottomstuff.asp"-->
<% End If %>
</body>
</html>

you can also use:
<script language="Javascript" src="include_files/bottomstuff.js"></script>
in place of the include files, but that would require ur HTML be printed using document.write

So if you want your infopage, you just call: infopage.asp
If you want the stripped page, you call: infopage.asp?plain=yes

topstuff.asp would contain your extra html stuffs for graphics and menus or whatever and bottomstuff.asp would contain the closing portion of it.

So at least this way, you don't have 2 versions of the same file and you can use topstuff and bottomstuff for all your pages and change they way it looks by using one page.
you could use PHP....

<!-- InstanceBeginEditable name="EditRegion3" -->

<?php


//
//      This is looking for 1 parameter and it supplies the
//  name of a file to display on the site.  
//

 $txtfile = 'php/files/' . $_REQUEST[Id] . '.txt';
      
if ($txtfile <> "null") {
      $Open = fopen ($txtfile, "r");
      if ($Open) {
            $data = file ($txtfile);
            for ($n = 0; $n < count($data); $n++) {
                  $GetLine = explode("\t",$data[$n]);
                  print ("$GetLine[0]<br>");
            }

            while ($n++ < 15) {
                  print ("<br>");
            }
            fclose ($Open);
      } else {
      print ("Error opening event file.");
      }
}

?>


    <!-- InstanceEndEditable -->


Oh, is that an editable region?  Why, yes it is.....  I CURRENTLY use this for a site.  Initally wanted to let the client update pages.  But they found it easier to let me do it....  The file is just a TEXT file created with NOTEPAD!!!  To use it:  http://www.abc.com/index.php?Id=home   My page is called INDEX.PHP and CONTENT is:HOME.TXT

Hope this helps!!!

Radnor,

How does that code help austerhaus write to two different files from one template from within DW?

Well....  He has ONE page (a template) for his site.    The URL reads in the BODY for the world to see.  Whoever need the "BODY" for their page has the SAME text file to work with.  Austerhaus said "they" will.....

To clarify, the stripped version is going to be used by another group that takes the contents of the file and uses server side code to wrap it in a different "frame"

So he will be creating the "body content" one time for BOTH sites to use....
Ah, okay.  

I didn't see where you were going with that initally.  

austerhaus,

No matter which solution you go with, it sounds like the page content is going to be called as an include on the server side.  Because DW templates are not server parsed, there is no good way to develop one locally that "writes" two different files upon being put to the remote server.  

You can fake it, somewhat, using a server side script that writes the content to a new file when it is accessed, but is more work than necessary.  Keep the content in separate files or in a SQL table and call the includes any way you like.
Thanks for the assistance. I awarded the points for jason1178 since he really answered the initial question. But thanks again for the responses.