JafSoft Support Forums  
  Products:
AscToHTM (text to HTML) / AscToPDF (text to PDF) / AscToRTF (text to RTF) / Detagger (HTML to text and markup removal) 

 
  Forum options:
Forum Index  Register  Login  Search  FAQ  Log Out
Member options:
My Profile  Inbox  Member List  Address Book  My Subscription  My Forums 
 
 

Note: Some forums require a login other than "Guest" in order to post messages and replies


How to use HTML Fragments to define a "template"

 
Logged in as: Guest
Users viewing this topic: none
  Printable Version
All Forums > [Hints and Tips] > [Tutorials and "How To"s] > AscToHTM and AscToRTF > How to use HTML Fragments to define a "template" Page: [1]
Login
Message << Older Topic   Newer Topic >
How to use HTML Fragments to define a "template" - 3/25/2006 4:04:32 PM   
Jaf

 

Posts: 70
Joined: 2/1/2006
Status: offline
AscToHTM doesn't currently offer a template function, but you can achieve much the same effect by using the "HTML fragments" feature.  In particular by defining HTML_HEADER and HTML_FOOTER fragments you can effectively place your generated HTML wherever you want inside standard HTML that you've defined.

Suppose you want to create a page that has the following HTML structure

  <div class="top_menu">
  ... (common menu code) ...
  </div>
  
  <table class="maintable" width="100%">
      <tr><td valign="top">
      <div class="main">

      ... (main body goes here) ....

      </div>
      </td></tr>
  </table>    <!-- end of main table -->
  
  <div class="footer_menu">
  ... (common footer code, copyright statements and disclaimers etc) ...
  </div>


You can split this into an HTML_HEADER fragment that is all the HTML code before where the main body goes, and an HTML_FOOTER that is all the code after it.

That is you define a HTML_HEADER as follows

$_$_DEFINE_HTML_FRAGMENT HTML_HEADER
  <div class="top_menu">
  ... (common menu code) ...
  </div>
  
  <table class="maintable" width="100%">
      <tr><td valign="top">
      <div class="main">
$_$_END_BLOCK


and an HTML_FOOTER like this

$_$_DEFINE_HTML_FRAGMENT HTML_FOOTER

      </div>
      </td></tr>
  </table>    <!-- end of main table -->
  
  <div class="footer_menu">
  ... (common footer code, copyright statements and disclaimers etc) ...
  </div>
$_$_END_BLOCK


Note, it doesn't matter if - as here - you've split the HTML code for a table between the two fragments.  All that means is that the HTML generated when AscToHTM converts your text will end up inside this table - which is usually part of what you want to achieve.

When AscToHTM converts your text, it will create the <BODY> and <HEAD> tags, then copy in the HTML_HEADER before outputting the converted HTML, after this it will append the HTML_FOOTER content and close the <BODY> tag.  The result is that you have an HTML file with the content you want converted from text, but with the overall layout and structure of a template created site, with standard menus headers and footers.  Much of the JafSoft web site is created in exactly this manner.

For more information, see the "Using HTML fragments" section of the AscToHTM manual included with your download.
 
Notes:
(1) The HTML_HEADER is inserted into the created document *after* the HTML <HEAD> section, i.e. immediately after the <BODY> tag.  To insert code into the <HEAD> section (e.g. some JavaScript or META tags) you can use the reserved fragment HTML_SCRIPT.

< Message edited by Jaf -- 5/27/2006 12:32:57 PM >
Post #: 1
Page:   [1]
All Forums > [Hints and Tips] > [Tutorials and "How To"s] > AscToHTM and AscToRTF > How to use HTML Fragments to define a "template" Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts