HTML Newsletter: Create Templates
From MontegoScriptsWiki
Main Page>>HTML Newsletter>>FAQ and How To
Contents |
The original author for this tutorial was mangaman from NukeWorks. I have adapted and edited the tutorial in order to keep up with the latest releases.
Introduction
One of the neatest features of the HTML Newsletter is the ability to make e-mail templates. We have tried to make it as easy as possible for the people who don't know PHP, yet still have a lot of power and configureability. With this template system you will be able to add images, table formatting, colors, font sizes, and all those things that make an HTML newsletter personalized to your web-site. You even can make your e-mail look like your web-site.
Off to the right of this page are sample graphics of the original templates provided with the HTML Newsletter tool -- they are still included to this day.
Placeholders
There are 2 things that are important to the template files, the Placeholders and Variables. The Placeholders are the items that will be replaced with the data from your website. These Placeholders are:
General Placeholders
- {AMOUNT} = This is the row counter, mainly used displaying the total number of items.
- {SITEURL} = This is the url of your site.
- {ROWNUMBER} = This is the row counter, mainly used for numbering the repeating rows. (row specific)
- {TOPICID} = This is the topic or category id number needed to do web links to the relative topic or category. (row specific)
- {TOPIC} = This is the name of the topic or category. (row specific)
- {TITLE} = This is the name of the item. (row specific)
- {HITS} = This is the number of times an Item has been hit. (row specific)
- {SITENAME} = This is the name of your site.
- {USERNAME} = This is the Users name the email will be sent to.
- {DATE} = The current date (i.e. January 01 2004).
- {TEXTBODY} = This is the main body of text or the message you wish sent.
- {BANNER} = This displays the Banners links.
- {NEWS} = This displays the News information.
- {DOWNLOADS} = This displays the download information.
- {WEBLINKS} = This displays the web-links information.
- {FORUMS} = This displays the forums information.
- {STATS} = This displays the site stats information.
- {EMAILTOPIC} = This displays the email topic.
- {SENDER} = This is the senders name.
- {ADMINEMAIL} = This is the Admin's email address.
- {TEMPLATENAME} = This is the template directory where all referenced objects can be found.
Specific Function Placeholders
- News Specific Placeholders
- {NEWSID} = This is the News id number needed to do web links to the news item.
- {AUTHOR} = This is the authors name.
- Download Specific Placeholders
- {DOWNLOADID} = This is the download id number needed to do web links.
- Web link Specific Placeholders
- {LINKID} = This is the Web link id number needed to do web links.
- Forum Specific Placeholders
- {FTOPICID} = This is the Topic id number needed to do web links.
- {FTOPICLASTPOSTID} = This is the Topic last post id number needed to do web links (use with {FTOPICID} to view the last post of that topic).
- {FTOPICTITLE} = This displays the Topic title.
- {FTOPICREPLIES} = This displays the topic replies.
- {FTPUSERID} = This is the user id of the Topic starter needed to do web links.
- {FTPUSERNAME} = This is the username of the topic starter.
- {FVIEWS} = This is the amount of views for the given topic.
- {FTIME} = This is the latest post time of given topic.
- {FUSERID} = This is the user id of the last poster needed to do web links.
- {FUSERNAME} = This is the username of the last poster.
- Site Stats Specific Placeholders
- {PAGEHITS} = This is the total page hits.
- {MEMBERS} = This is the total members.
- {NEWSITEMS} = This is the total news items.
- {NEWSCAT} = This is the total news categories.
- {DOWNLOADS} = This is the total downloads.
- {DOWNLOADCAT} = This is the total download categories.
- {WEBLINKS} = This is the total web-links.
- {WEBLINKCAT} = This is the total web-links categories.
- {FORUMPOSTS} = This is the total forum posts.
- {FORUMTOPICS} = This is the total forum topics.
- Newsletter Table of Contents Specific Placeholders
- {TOCLINK} = This is the href name for the bookmark.
- {TOCLINKTEXT} = This is the link name for the bookmark that the user sees.
Variables
Variables hold the different sections of the templates, these PHP variables will hold the HTML code we will use to build your template. Don't worry if you don't know PHP, variables are quite easy to use, you will get the hang of it quickly (more in section 3). These Variables are:
- $statstable = Where the code for the site stats is placed.
- $emailfile = The main body of the email.
There are 4 sets of 3 that all have the same basic function, and these are:
- $latestnewstop
- $latestnewsrow
- $latestnewsend
- $latestdownloadtop
- $latestdownloadrow
- $latestdownloadend
- $latestweblinktop
- $latestweblinkrow
- $latestweblinkend
- $latestforumtop
- $latestforumrow
- $latestforumend
Now as you can tell the 4 sets are news, download, web link, and forum. Since we can select how many rows to display we had to separate the tables into thirds called "top", "row", and "end". The "top" var (short for variable) is the top part of the table, "row" is the repeated row that is filled with the main part of the data, and "end" is the end or bottom of the table.
Next, are three additional variables for controlling a newsletter table of contents "block":
- $newscontentstop
- $newscontentsrow
- $newscontentsend
These are used in a similar fashion as the above blocks for "Latest".
Creating Your Own Template
Now it is time to put these variables to work. First we create a file and name it template.php. For those who don't know PHP this has very little PHP code so you don't need to worry, if you have done even a little Javascript or PHP this will be easy.
Now we open our template file and insert the PHP start and end tags. These will be at the top and bottom of the page and all the other code will go in-between, like this:
<?php (this is where the code goes) ?>
Next come the variables:
TBD

