Can I extract a template I like from a PortWeb generated page?


<< Can I do a PortWeb Find ( ...
Back to Portfolio FAQ index
Can I generate email from ... >>

Those who find template authoring from scratch a bit difficult often ask if they can just 'save' a template from a PortWeb generated page.

So, can you save out templates? The simple answer is 'No', but in fact you can in many cases reverse engineer the template by saving out a result page and using logic to figure out the source HTML code. Whilst coding thrives on "re-use" if you do want to use someone else's templates, especially for a public project, than it is polite at least to ask before you do so. You may be lucky and they may give you the template code.

Anyway, if you do have to figure out a template in reverse, here's a way to go about it:

  1. Do a query which yields more than one page of results and look at the first result page. From this you now know the number of 'item' rows and columns by the number of sets or result data shown on the page. Save the page and make a note of these settings.
  2. Try and do a query that only yields a single result in the same template as this will have only one item's worth of 'item' template code. Save this page. If you can't do this make a copy of the page saved in Step 1.
  3. How to you spot the item(s) in the HTML? Start at the end of the item section as this will be marked by an HTML comment <!-- This document generated by the Portfolio 5.0 Web Plug-in --> or similar, depending on the PortWeb version. Immediately before this will be an uppercase </TR> tag. Now, track back up the page looking for the opening <tr> tag (it's easier if the template author uses lowercase tags and indents their code!). Use text or formatting in the HTML page to help you see where the Header section of the saved ends. Now, delete the item section code until you only have code for a single item.
  4. You should end up identifying three 'sections' of the page. Put <!--Port4-Header--> at the very top line of the page source and <!--/Port4-Header--><!--Port4-Item--> immediately before the Item section code starts. Repeat, with <!--/Port4-Item--><!--Port4-Footer--> at the end of the Item section and <!--/Port4-Footer--> on the last line of the source. Save the file.
  5. Now go through each section replacing code with PortWeb macros, e.g. for the actual code linking to the next result page, substitute %next%. Refer to the manual pages 277-291. You will need to experiment a bit. Don't forget that to use a macro for a Catalogue field, such as Description use the correct capitalisation, thus %Description% and not %description% as the latter will not return any information.
  6. Open your Catalogue in the client, and select File -> Export -> HTML and then the 'Add...' button. The Edit HTML dialog opens. Ignore the code you see and click the 'Import...' button. Navigate to your saved page and import it. If you have set up the template markers correctly in Step 4 the code will split neatly between the three Header/Item/Footer tab boxes.
  7. In the boxes at the top of the tab type the name you will use for your template and the row and column numbers you worked out in Step 1. Now click save.
  8. Your template is done - time to test and tune.


Question: Can I extract a template I like from a PortWeb generated page? [FAQ00210.htm]
Last Update:- 01 June 2006


<< Can I do a PortWeb Find ( ...
Back to Portfolio FAQ index
Can I generate email from ... >>

Quick Search of PortfolioFAQ (word, words or phase): or try the Advanced Search

User-to-User Forums  |  Report error/typo/broken link  |  Request new topic  |  Ask a question

Site and articles © Mark Anderson 2001-2007 - Visit my home page


This FAQ is created and maintained using
Friday logo
Friday - The Automatic FAQ Maker