<p class="lead" align="left">
Creating/Modifying Site Templates
</p>
<p>
<a href="http://74.200.215.186/members/118.cfm">Working With Templates Part One</a>
</p>
<p>
<a href="http://74.200.215.186/members/119.cfm">Working With Templates Part Two</a>
</p>
<p>
<a href="http://74.200.215.186/members/120.cfm">Working With Templates Part Three</a>
</p>
<p>
<a href="http://74.200.215.186/members/129.cfm">Working With Templates Part Four</a>
</p>
<p>
The templates for generated sites are stored in the wcb/asgen/templates
directory. The template subdirectory name is the template name that is
seen in the main forms for the API (main page), the batch upload form (
wcb/batchupload.php ) and in the profile<img src="http://74.200.215.186/members/images/102a.jpg" align="right" border="0" height="266" hspace="5" vspace="5" width="115" /> section. The template
subdirectory should be named with no spaces or special characters and
should be as short as possible while still being descriptive.
</p>
<p>
There is one default template set named 'default' (
wcb/asgen/templates/default ). To use the default template, simply
select it in the profile form when creating a new profile. All
subdirectories within the wcb/asgen/template directory will show up in
the template drop-down list box in the forms. Templates can be shared
with multiple profiles.<!--BEGIN Image 1 TABLE -->
<table align="right" border="0" cellpadding="0" cellspacing="0">
	<tbody>
		<tr valign="top">
			<td width="115"><br />
			<span class="photocap">  
			</span><br />
			</td>
			<td><img src="http://74.200.215.186/members/images/space.gif" border="0" height="1" width="10" />
			</td>
		</tr>
	</tbody>
</table>
<!--End Image 1 TABLE --> 
</p>
<p>
The template directories also contain several subdirectories for scripts.
These need to remain intact. The entire contents of the
template/templatename directory gets uploaded to each site generated.
The scripts contained in the subdirectories will actually handle
creating all of the web pages.
</p>
<p>
To create a new template, it is highly recommended you first copy the default template to a new
directory such as 'Template1' or 'AdSense_Box1' or whatever you desire,
so you will have all of the files needed. The template consists of the
html page templates and several support files such as scripts and data.
When a site is generated several other files are uploaded that contain
the keyword phrases for the site. A cronjob script runs on the site
side to actually generate the web pages. They are built using the html
templates.
</p>
<p>
The template directory (Example:wcb/asgen/templates/Template_name) will become the home directory of
the generated web site, such as /home/username/www or
/home/username/public_html. The entire contents of the template
directory are copied to the generated site completely intact. So to
include items such as images, you would put them in the
wcb/asgen/template/Template_name/images folder. On the site side, that
translates to /home/username/www/images or <a href="http://yourdomain.com/images" target="_blank">http://yourdomain.com/images</a>. 
</p>
<p>
In the template directory there is a subdirectory named '_sitefiles'. This
is where the main html page templates go. There are 4 page templates
that need to exist:
</p>
<p>
article.html
index.html
subarticle.html
subindex.html
</p>
<p>
The article.html page is for having an article on a separate page. The
article is automatically inserted into the page. It is not linked from
anywhere by default. It can be linked from any page by placing a tag in
the page where you want the link. The tag is {ARTICLELINK} and must
include the braces and must be all uppercase.
</p>
<p>
The index.html page is for the main home page and for each keyphrase page residing in the
home directory. The subindex.html is for the subdirectory/index.html
pages. It should be the same as the index.html except all relative
paths should point to the previous directory ( &quot;../&quot; ) for the home
directory. The subarticle.html is for the subdirectory/article.html and
relative paths in that should also point to previous directory (&quot;../&quot;)
for the home directory. The index.html in the home directory is created
using the primary keyword or phrase.
</p>
<p>
Note that the builder has 4
options for building the pages. Even though the templates must be named
with .html extensions, the generated pages may end with .php or .html
depending which option you select in the profile. For 100% search
engine friendliness we recommend using the .html extension.
</p>
<p>
The page options allow you to have all html pages within the home directory
and would be named with keyphrase.html or keyphrase.php (with any
spaces removed automatically). Or you can have a single index.html or
index.php for the home page and the keyphrases will be subdirectories
with an index.html or index.php within it. As an example if you had
&quot;Dog Guide&quot; and &quot;Dog Food&quot; for keyphrases the following would be the
various versions:
</p>
<p>
/dogguide.html  or .php
/dogfood.html  or .php
</p>
<p>
/dogguide/index.html  or .php
/dogfood/index.html  or .php
</p>
<p>
If you also insert dashes for spaces the options are:
</p>
<p>
/dog-guide.html  or .php
/dog-food.html  or .php
</p>
<p>
/dog-guide/index.html  or .php
/dog-food/index.html  or .php
</p>
<p>
There are several tags that can be used in the page templates. All of the
tags must be all uppercase and include opening and closing brackets
(i.e. {TAGNAME} ).
</p>
<p>
{AUTOXML} -- Inserts alternate xml version link within the page header. Should be placed between the tags.
</p>
<p>
{RSSLINK} -- Inserts a link to an xml version of the page.
</p>
<p>
{ARTICLE} -- Inserts a markov generated article. To insert a real quoted article you must us a php include tag, as follows:
</p>
<p>
{ARTICLELINK} -- Inserts a link to the article.html or article.php. Text is 'View Article'.
</p>
<p>
{COPYRIGHT} -- Inserts a copyright notice with the current year ('Copyright © yyyy ')
</p>
<p>
{DESCTEXT} -- Inserts keyword/phrase
</p>
<p>
{KEYWORD} -- Inserts keyword/phrase
</p>
<p>
{KEYWORDLINK} -- Inserts a link to the keyword page (uses keyword/phrase for text)
</p>
<p>
{PRIMARYKW} -- Inserts the primary keyword/phrase (topic)
</p>
<p>
{PRIMARYLINK} -- Inserts a link to the primary keyword (normally the home page)
</p>
<p>
{PRIVACYLINK} -- Inserts a link to the privacy page
</p>
<p>
{RANDOMKW} -- Inserts a random keyword/phrase from the phrases used for the site
</p>
<p>
{RANDOMLINK} -- Inserts a link to a random keyword/phrase page (with keyword/phrase as text).
</p>
<p>
{SITEURL} -- Inserts the web site url including http://
</p>
<p>
{SITELINKS} -- Inserts a list of random links for sidebar(s) (multiple sidebars can be used)
</p>
<p>
{SITEMAPLINK}
-- Inserts a link to the sitemap, which contains a list of all of the
keyword/phrases with a snippet of the article. Text is 'Sitemap'
</p>
<p>
{SNIPPET} -- Inserts a snippet of the article text.
</p>
<p>
{TERMSLINK} -- Inserts a link to the Terms page.
</p>
<p>
{USERNAME} -- Inserts the username of the site. Used for building paths for embedded php and/or javascript. (Example:  )
</p>
<p>
Added Feb 12:
</p>
<p>
{KEYWORDALLCAPS} - Keyword All uppercase
</p>
<p>
{PRIMARYKWALLCAPS} - Primary Keyword All uppercase
</p>
<p>
{KEYWORDCAPS} - Keyword First Letter Of Each Word Caps
</p>
<p>
{PRIMARYKWCAPS} - Primary Keyword First Letter Of Each Word Caps
</p>
<p>
{KEYWORDNOSPC} - Keyword with spaces removed
</p>
<p>
{PRIMARYKWNOSPC} - Primary keyword with spaces removed
</p>
<p>
{BUILDDATE} - Inserts date as YYYY-MM-DD
</p>
<p>
{BUILDDATETIME} - Inserts date and time as YYYY-MM-DD HH:MM:SS
</p>
<p>
Embedded PHP Code
</p>
<p>
There are segments of embedded PHP code in the page templates. If you create
a new template it is important to insert the segments in the correct
place. Otherwise the photos, videos and/or articles will not work
properly, if at all.
</p>
<p>
Your hosting servers must also be setup to execute php code embedded inside html. If photos, videos and articles
are not working even with the default template, then Apache is probably
not setup to execute embedded php. In order to do that an extra entry
is required in the Apache configuration file. Edit the Apache
configuration file (/etc/httpd/conf/httpd.conf or
/usr/local/apache/conf/httpd.conf typically) and look for a line that
looks like this:
</p>
<p>
DirectoryIndex index.html index.html.var
</p>
<p>
Change it to this:
</p>
<p>
DirectoryIndex index.html index.html.var index.php
</p>
<p>
Then restart Apache using: /etc/rc.d/init.d/httpd restart from SSH. See the
section about Setting Up Hosting Servers for more information.
Photos
</p>
<p>
To display photos on generated sites based on the keyword
the following code must appear inside the template html code before any
calls to the photo.php script:
</p>
<p>
The photo.php script uses these variables to determine what photos to fetch through the
Flickr API. The $primaryKW gets set to the main keyword the site was
built using. The $kwd is set to the keyword/phrase for the page itself.
(Will be the same for the home page). The {} tags are filled in
automatically by the site generator when the page is built, so do not
modify those.
</p>
<p>
You can set some options, such as the width and height of the photos ($w and $h). The $orient sets orientation, either
h for horizontal or v for vertical. The $vs and $hs set the vertical
space and horizontal space for the img tag. The $dnum sets how many
photos to actually display. The default is 4. You can set the img align
tag with $al. Note, absmiddle does not work with these pages because
they are XHTML compatible.
</p>
<p>
After the variables are set you can call the photo.php anywhere in the page below this code. Simply copy
the last line: require($hdir . &quot;photo.php&quot;); and paste where you want
the photos displayed. You can also use it multiple times, if desired.
For example you could display 4 photos in the header and then 1 photo
somewhere else in the page. Note, in order to display additional
photos, yo must use a call to the dspImage() function. There can only
be one instance of require($hdir . &quot;photo.php&quot;); in the page. 
</p>
<p>
So to display an additional photo you must set the $dnum=1; then call
dspImage(). The first require line automatically calls the dspImage()
function internally in the script. So dspImage() is only needed for
subsequent photo displays.
</p>
<p>
Example:
</p>
<p>
If you do not wish to use photos, that is fine. But you must keep a portion of the
code mentioned above for other embedded scripts to work properly. So
make sure you at least have this code before the others are used:
</p>
<p>
Videos
</p>
<p>
Videos from YouTube can be displayed based on the keyword , as well. Simply
insert the following code after the main photo code (see above):
</p>
<p>
The video.php shares the $hdir, $primaryKW and $kwd variables.
</p>
<p>
Articles
</p>
<p>
There are 2 types of articles that can be used with the sites. The first is
simply a markov generated article based on harvested sentences tied to
the keywords. To insert a markov article use this tag:
</p>
<p>
{ARTICLE}
</p>
<p>
If you do not want to use a markov article, simple remove all of the
{ARTICLE} tags in the templates. Do not delete the
_sitefiles/scripts/markov.php file, otherwise the sites cannot generate
ever again.
</p>
<p>
The second article type is a real article pulled from an article site, such as Ezine Articles. These will appear properly
quoted/credited to prevent legal copyright issues. Providing the source
is properly listed, you don't have to worry about it. These articles
have the source listed at the end of the article. Do not defeat this
feature. Doing so will put you at risk for legal issues, and we will
not be responsible for such.
</p>
<p>
To insert these articles use this code:
</p>
<p>
The first line simply inserts the current date. This is recommended
so each page load appears to be fresh content. These articles are
pooled in the /article directory and a random one is chosen on each
page load. Note, some keywords may not produce very many articles, and
possibly none at all. To ensure there is an article on each page, we
recommend using both the markov and real article code. You can also
change the keyword for the site and rebuild.
</p>
<p>
This must also appear after the main photo code, as it shares the $primaryKW, $kwd and
$hdir variables. Also note, the script for this is named art.php not
article.php. The reason is that an article.php will exist in the home
directory if you selected .php for the page option in the builder, and
is a completely different entity.
</p>
<p>
Troubleshooting Templates
</p>
<p>
As
mentioned earlier, all of the subdirectories and files in the template
directory must be uploaded to each site. If you have created a new
template and uploaded into the builder's /wcb/asgen/template/ folder,
make sure all of the subdirectories are there, even empty ones.
</p>
<p>
The best way to create a new template is to copy the default template
included in the package to a new directory. Then modify the
_sitefiles/*.html pages as needed.
</p>
<p>
One subdirectory in particular
can cause issues if not present. There should be a /temp directory in
the upd directory(i.e. /wcb/asgen/templates/TemplateName/upd/temp ). If
this is not present, the sites will not build. The site accounts will
get created and uploaded, but the actual pages will not generate.
</p>
<p>
If this occurs, simply modify your template so it does include the
upd/temp then re-upload the sites. You can either do them individually
from the report section or simply do a Template Update from the Updates
section. To upload individually, pull up the report page and then pull
a report for the Site Uploads. The domains will be listed along with
their status. In the status section it should say UPLOAD_COMPLETE. To
the right of that there is a small icon with a red double arrow. ?<!--BEGIN Image 2 TABLE -->
<table align="center" border="0" cellpadding="0" cellspacing="0">
	<tbody>
		<tr valign="top">
			<td width="400"><img src="http://74.200.215.186/members/images/102b.jpg" border="0" height="77" hspace="5" vspace="5" width="400" /><br />
			<span class="photocap">  
			</span><br />
			</td>
			<td><img src="http://74.200.215.186/members/images/space.gif" height="1" width="10" />
			</td>
		</tr>
	</tbody>
</table>
<!--End Image 2 TABLE --> 
</p>
<p>
If you click that icon, a popup will come up saying:
</p>
<p>
URL: domainname.com
Scheduled for regeneration.?It should complete in a minute or two...
</p>
<p>
Close that popup. And shortly thereafter the site will re-upload. What this
does is sets the site status to UPLOAD_FAILED, which will trigger
another upload attempt. Note, using this method may cause content to
change, as well. So using the Template Update is recommended if you
wish to maintain the content. Note, popups must be enabled in your
browser to see the message window. It is not required, though the
function will still work if you click the icon.
</p>
<p>
Make sure you
haven't left out any of the other folders and files from the template
folder. Any missing files may cause the site generator to fail. 
</p>
<p>
Another issue may be with the cronjob that runs on the uploaded web site. If
the cron does not run, the site will not generate. This cron is
scheduled to run within a 60 minute window. So sites will not generate
immediately. This is done to spread out the load for the hosting
server. Normally, there would be no more than 4 sites generating
simultaneously. If there are, it could be due to a slow server, or you
selected a large number of keywords to build with (&gt; 300). Normally,
you will not need to worry if the load is somewhat high, as it is only
temporary and will drop.
</p>
<p>
Once the site is generated, the cronjob is automatically modified to run once per day at a random time from
00:00 to 23:59. This is done for the tag/ping feature which only needs
to run once per day. Note, any site updates will restart the sequences.
</p>
<p>
If the cronjob does not appear to run at all, you can check the cron
directory to see if it is present for the site's username. Login to the
server as user root, then cd /var/spool/cron and then type ls --l to
get a directory list. You should see a list of usernames , 1 per site
and possibly root. To view the contents of a cron file type: cat
username and press enter. It should list the contents.
</p>
If the cronjob is not present, then an error occurred during upload. If there
are no cronjobs listed for any of the sites, then it is possible php is
not allowed to run crontab from shell_exec on t
