Will it oint?

Oronine Ointment
Otsuka Seiyaku
Skin Cleanser and Moisturizer

Water – gives it the liquid feeling
PEG-6-32 – not recommended for use on damaged skin but good enough for cosmetics; not reassuring
stearyl alcohol – environmental toxin that causes cancer in high doses and is known to irritate skin; thickener
glycerin – smooths skin; laxative
beeswax – magical acne curing properties
petrolatum – lubrication
lauromacrogol – treats pain, inflammation, and itching; numbing effect; and haemorrhoids; anal itch
olive oil – nature’s healing
chlorhexidine digluconate – anti-bacterial agent; may cause cancer
fragrance – medicinal smell

Otsuka Pharm. Factory, Inc
Tokushima, Japan

I have no clue why I wrote this post above; but it would be a shame not to release it to the world.


Installing Smarty in Cpanel

At my workplace, Smarty is used to divide the work between back-end and front-end engineers. I wanted to fiddle around with it on my free time, but there weren’t any concrete step-by-step instructions for installing Smarty in cPanel among the first few search result links on Google.

Here is what I did by following these basic instructions from Smarty’s Basic Installation page:

A typical shared host file structure looks like this in cPanel 11:


I downloaded the latest Smarty package which in my case is Smarty 3.0.7 and uploaded the compressed file into the etc folder. I decompressed the file using the handy extract feature in the cPanel menu. I ended up with this structure:


Next, I moved the content from demo to public_html so it can be accessible to the world. This left me with this structure:


At this point, you should change the permissions on the cache and templates_c folders to 777 for caching purposes.

Smarty also instructs its users to either define a constant for the path to the Smarty libraries or include the absolute path in php.ini. For those who are forgetful like myself, I chose to do the latter.

If you do not have access to the actual php.ini or your host is inflexible, you can just create one in your public_html directory. Add this line to the file:

include_path = ".:/usr/lib/php:/usr/local/lib/php:/home/username/etc/Smarty-3.0.7/libs/"

The path to your PHP libraries can either be found through the PHP Information menu item on cPanel’s main page or executing phpinfo() in a script.

To hide php.ini from prying eyes, edit your .htaccess file and drop this at the end:

<FilesMatch "(\.ini)$">
Order allow,deny

The above will return a 403 Forbidden error to anyone who tries to access files ending in .ini.

Some of you may not see the .htaccess file in cPanel. To make it viewable, you would of had to check the See hidden files checkbox on the popup after clicking on File Manager. To make the popup appear again, go to your cPanel main menu and click on the reset all interface settings link in the footer. You can also gain access to the .htaccess file by navigating to your website through an FPT program.

Now edit the index.php that is in the public_html directory. Replace this line:




This can be done because the absolute path to the Smarty libraries had been established in the php.ini file earlier.

Navigate to your site in your browser and the example Smarty page should pop up. If you receive an error about a popup init in the header.tpl, just go to the file under the templates directory and remove the line. Supposedly, Smarty packages after 3.0.7 will have the line removed.

And there we go. Fun for the entire family.


What is Use Tax?

I read an article today about Amazon threatening to cut all ties with their affiliates if California passes the law to have Amazon collect sales tax on purchases made by California residents.

Amazon does not want to include sales taxes in their prices because they do not want to act as a tax collector for a state they do not reside in, which is probably bullshit. Amazon is able to profit in California by not including sales tax in their prices. When a customer compares an Amazon price sans sales tax with a local store that includes sales tax, they will most likely purchase from Amazon.

California’s state government is flat out broke. They need money from any avenue they can find. This tax loophole has been open for the past decade. With the number of consumers going online to make their purchases, revenue from sales taxes has been shrinking. To remedy this loss, California wants all out-of-state retailers who sell to residents in this state to collect the state’s sale tax. They targeted Amazon because it’s the biggest fish in the pond.

For the state to collect on sales tax from an out-of-state company, the company must have a physical presence in this state. Amazon does not have a retail store in California, I am not sure if they even have a distribution center here. But they do have affiliates–webmasters who drive traffic to Amazon to collect on commissions from customer purchases. These affiliates reside in California, so in a roundabout way, Amazon does have a physical presence in the state.

Amazon stance is to sever ties with all California affiliates, thus removing their physical presence in the state. In this manner, they will continue to sell their products to California residents without applying sales tax. They will have to retroactively pay for the sales tax incurred from past purchases which would amount to a couple hundred million. California will lose out on the extra income taxes from resident affiliates. And the affiliates will lose a source of income.

Who is to blame for all this? Everyone who buys products online and don’t pay the Use Tax at the end of the year. Random guy remarks, “You’re crazy! What is this Use Tax? I’ve never heard of it in my life! Stop making shit up!”

No, my friend, the Use Tax is all too real. The law has been in the books since 1935 but it referred mostly to catalogs at the time. In 2003, a line for use tax was added to the state income tax form. California requires residents to pay a tax on purchases of taxable products from out-of-state companies that do not collect sales tax. The Use Tax rate is the same as our sales tax.

So, if you saw and bought that sweet 3D TV deal for ~$2000 from Amazon, when tax day rolls around, you need to pay ~$200 in Use Tax to California. This also applies to those few who cross state lines to buy products from Oregon tax-free and bring them back to California. You know who you are. Don’t try to cheat the system.

And on that note, go buy something from Amazon through this link which has an affiliate id attached. The affiliate is not mine but a friend who needs funds to satisfy his otaku needs. Otakus Unite!


PHPLD Template Tutorial – Part 4

In Part 3, we familiarized ourselves with the variables passed from the code side to the templates. Today, we learn the specific variables passed from the PHP files to their respective templates.

init.php => all templates
$core_templates, VERSION, $MetaRobots, $MetaKeywords, $MetaDescription, $MetaAuthor, $MetaCopyright, $load_Javascript, $regular_user_details, $stats, $mainCategs, $latest_art, $featuredlinks, $regularlinks, $random_link, $scriptname, $maincontent, $pages
Note: The variables above are available for all templates.

index.php => header.tpl
$tdescription, $TITLE, $ADDRESS, $search, $in_page_title, $links, $category, $scriptname

index.php => top_nav.tpl
$cat, $category, $current_path, $list, $p, $path, $search

index.php => footer.tpl

index.php => main.tpl
$sort, $list, $have_search_results, $uid, $search, $search_terms, $list_cat, $search_category, $list_articles, $search_article, $title_prefix, $feat_links, $category, $path, $count, $links, $articles, $categs, $p, $StopLinkHits, $MetaKeywords, $MetaDescription

login.php => login.tpl
$no_permission, $failed, $path

page.php => page.tpl
$data, $path, $MetaKeywords, $MetaDescription, $error

add_reciprocal.php => add_reciprocal.tpl
$link_id_error, $posted, $sql_error, $path, $data

article.php => article.tpl
$imagehash, $COMMENT, $img_verification_error, $commentError, $ratingError, $error, $comments, $rating_disabled, $logged_comment, $logged_rating, $captcha_length, $path, $data, $MetaKeywords, $MetaDescription, $ratings_on, $comments_on, $SITE_NAME

author.php => author.tpl
$error, $path, $data, $SITE_NAME, $MetaKeywords, $MetaDescription

categ_tree.php => category_tree.tpl
$CategoryTitle, $parentID, $categoryList, $categID, $action, $error_cat_tree

contact.php => contact.tpl
$imagehash, $path, $contactSent, $_POST, $captcha_length, $data, $error, $errorMsg

detail.php => detail.tpl
$error, $path, $data, $MetaKeywords, $MetaDescription

payment.php => payment.tpl
payment.php => paypal.tpl
$Subscription, $SubLength, $PAYMENT, $error, $quantity, $subscribe, $price, $action, $path, $SubscribeOptions, $data, $payment_um, $SubscriptionEnabled, $SubscriptionPeriod, $SubscriptionUm

profile.php => profile.tpl
$thank_you, $confirm, $password_recovered, $imagehash, $send_password, $email_sent, $email_error_msg, $email_status, $wrong_user_details, $_POST, $data, $agreement_terms, $user_registration, $user_edit, $imagehash, $languages, $user_info, $error, $errorMsg, $profileUpdate, $InfoLimit, $yesno, $captcha_length, $registration_errors, $path, $SITE_NAME, $ALLOW_AUTHOR_INFO

rss.php => rss2.tpl
$title, $lart, $description, $url, $links

rules.php => rules.tpl
$data, $path, $SITE_NAME, $rules

search.php => article_search.tpl
search.php => category_search.tpl
search.php => search.tpl
$printSearchPage, $have_search_results, $MetaRobots, $error, $errorMsg, $path, $searchquery, $list_cat, $search_category, $list_articles, $search_article, $links, $printSearchPage, $path, $titleonlyOptions, $locationOptions, $hitlessOptions, $sortbyOptions, $sortorderOptions, $data

submit.php => submit.tpl
$imagehash, $path, $useRTE, $SubscriptionF, $SubscriptionN, $SubscriptionR, $price, $recpr_required, $ShowReciprField, $double_review, $AllowedFeat, $secondBanCheck, $posted, $error, $_POST, $DescriptionLimit, $MetaDescriptionLimit, $disablereason, $allowedTags, $allowedAttr, $captcha_length, $remove_link, $review_link, $categs, $SubscriptionEnabled, $payment_um, $load_Javascript, $CategoryTitle, $data, $LINK_TYPE

submit_article.php => submit_article.tpl
$imagehash, $path, $useRTE, $double_review, $posted, $error, $_POST, $allowedTags, $allowedAttr, $DescriptionLimit, $ArticleLimit, $MetaDescriptionLimit, $disablearticlereason, $captcha_length, $remove_article, $review_article, $categs, $load_Javascript, $prurl, $CategoryID, $CategoryTitle, $data, $SITE_NAME

unauthorized.php => unauthorized.tpl


PHPLD Template Tutorial – Part 3

Now that we know the smarty tags from Part 2, we can learn about the variables passed to the templates for Smarty to manipulate:

$_POST – array; data returned from a form
$data – array; data returned from a query; different for each page
$stats – array; tally of various stats; fields:
   statActiveLinks – integer; tally of active links in directory
   statPendingLinks – integer; tally of pending links waiting for validation
   statTodaysLinks – integer; tally of links validated during the current day
   statArticles – integer; tally of active articles in directory
   statCategories – integer; tally of active categories in directory
   statsSubCategories – integer; tally of active subcategories in directory
$user_info – array; user info; fields:
   ID – integer; user unique identification number
   LOGIN – integer; user’s login name
   NAME – integer; user’s real name
   PASSWORD – integer; user’s password
   LEVEL – integer; user’s group level
   RANK – integer;
   ACTIVE – integer; whether the user is active
   LAST_LOGIN – date; last time the user logged in
   REGISTRATION_DATE – date; when the user registered
   SUBMIT_NOTIF – integer;
   PAYMENT_NOTIF – integer;
   ADDRESS – string; user’s address
   EMAIL – string; user’s email address
   WEBSITE – string; link to user’s website
   WEBSITE_NAME – string; user’s website’s name
   INFO – string
   ANONYMOUS – integer; whether the user submits articles anonymously
   LANGUAGE – string; language the user uses
   AVATAR – string;
   ICQ – string; user’s ICQ number
   AIM – string; user’s AIM name
   YIM – string; user’s Yahoo IM name
   MSN – string; user’s MSN name
   CONFIRM – string;
   NEW_PASSWORD – string; user’s new password
$agreement_terms – integer; whether or not the user agreed to the terms during registration
ALLOW_AUTHOR_INFO – const; set in admin to determine if author’s info shows up in articles
$allowedAttr – string; allowed attributes during article/link submission; default: none
$AllowedFeat – boolean; determines if categories have featured links
$allowedTags – string; allowed html tags during article/link submission; default: b, strong, i, u, strike, span
$ArticleLimit – integer; difference between the max article length and actual article length or the max article length if the actual article length is greater
$articles -2D array; list of articles; fields:
   ID – integer; unique id number for article
   TITLE – string; article title
   DESCRIPTION – string; article blurb seen in the listings
   ARTICLE – string; article content
   CATEGORY_ID – integer; category id the article belongs to
   STATUS – integer;
   VALID – integer;
   RATING – integer; article average rating by the users
   VOTES – integer; tally of user ratings
   COMMENT_COUNT – integer; tally of user comments
   OWNER_ID – integer; the author’s id
   OWNER_NAME – integer; the author’s name
   OWNER_EMAIL – string; the author’s email address
   OWNER_NOTIF – integer;
   DATE_MODIFIED – date; last time article was edited
   DATE_ADDED – date; when the article was submitted
   FEATURED_MAIN – integer; whether the article should appear on the main page
   FEATURED – integer; whether the article should appear first in its category
   EXPIRY_DATE – date; when the article should become hidden from view
   PAYED – integer; whether the author paid to post article
   ARTICLE_TYPE – integer;
   IPADDRESS – string; author’s ip address
   DOMAIN – string;
   OTHER_INFO – string;
   MAIN_KEYWORDS – string; keywords used in meta tag for article page
   MAIN_DESCRIPTION – string; description used in meta tag for article page
$captcha_length – integer; length of captcha phrase set in admin; default: 5
$categID – integer; category ID
$category – string;
$CategoryID – integer; category ID or 0 if invalid category
$categoryList – 2D array; list of categories; fields:
   ID – integer; category ID
   TITLE – string; category name
   SUBCATEGS – integer; 1=has sub categories, 0=does not have sub categories
$CategoryTitle – string; category name
$categs – 2D array; category info–could contain the same fields as $categoryList or it could contain the fields below:
   ID – integer; category id
   TITLE – string; category’s name
   CACHE_TITLE – string; category’s name preceded by its parent category’s name
   TITLE_URL – string; stub representing category to be used in determining it’s URL
   CACHE_URL – string; current category’s stub preceded by its parent stub
   DESCRIPTION – string; description of the category
   TDESCRIPTION – string; browser title
   CATCONTENT – string;
   PARENT_ID – integer; current category’s parent category’s id
   STATUS – integer;
   DATE_ADDED – date; date category was added to the directory
   HITS – integer; count of clicks on category
   SYMBOLIC – integer;
   SYMBOLIC_ID – integer;
   META_KEYWORDS – string; category’s meta keywords
   META_DESCRIPTIONS – string; category’s meta descriptions
   SUBCATS – optional 2D array; same data as above but for the sub categories
   COUNT – integer; tally of categories and links associated with the current category
$COMMENT – string; user’s comment for an article
$commentError – integer; 1=issue with comment
$comments – 2D array; list of comments for an article; fields:
   ID – integer; comment unique id
   ARTICLE_ID – integer; article id being commented on
   USER_ID – integer; id of user who made comment
   USER_NAME – string; name of user who made comment
   COMMENT – string; user’s comment
   DATE_ADDED – date; when user made comment
   IDADDRESS – string; ip address of user who made comment
   STATUS – integer; whether to show comment
$comments_on – integer; whether to allow comments; 0=no, 1=yes
$confirm – integer; determines if user logged in correctly
$contactSent – integer; determines if email was sent; 0=no, 1=yes
$core_templates – string; name of templates to be used for admin
$count – integer; tally of links
$description – string; search result message or category description
$DescriptionLimit – integer; difference between the max meta description length and actual meta description length or the max meta description length if the actual meta description length is greater
$disablearticlereason – string; message for why article submission is disabled
$disablereason – string; message for why directory is disabled
$double_review – string; message to inform user the link/article has not been reviewed yet
$email_error_msg – string; message for why email failed to be sent
$email_sent – string; confirmation message for when email has been sent; fail=error, success=sent
$email_status – integer; status code for when the send email script has completed
$error – string; error message
$error_cat_tree – integer; issue with category tree; 0=no issue, 1=issue
$errorMsg – string; email error message or search error message
$failed – boolean; true=login failure
$feat_links – 2D array; list of featured links; fields:
   ID – integer; link unique id
   TITLE – string; link title
   DESCRIPTION – string; link description
   URL – string; link url
   ADDRESS – string;
   CITY – string;
   STATE – string;
   ZIP – string;
   PHONE_NUMBER – string;
   CATEGORY_ID – integer; category id the link belongs to
   RECPR_URL – string; reciprocal url
   RECPR_REQUIRED – integer; whether or not a reciprocal url is required during link submission
   STATUS – integer;
   VALID – integer; whether link is valid
   RECPR_VALID – string; whether reciprocal link is valid
   OWNER_ID – integer; user id of link submitter
   OWNER_NAME – string user name of link submitter
   OWNER_EMAIL – string; user email of link submitter
   OWNER_NOTIF – integer;
   DATE_MODIFIED – date; when the link was updated
   DATE_ADDED – date; when the link was submitted
   HITS – integer; tally of clicks the link has
   LAST_CHECKED – date; last time link was checked for validity
   RECPR_LAST_CHECKED – date; last time reciprocal link was checked for validity
   PAGERANK – integer; google page rank of link
   RECPR_PAGERANK – integer; google page rank of reciprocal link
   FEATURED_MAIN – integer; whether or not link should appear on main page
   FEATURED – integer; whether or not link should be featured in category page
   EXPIRY_DATE – date; when the link will no longer be featured
   NOFOLLOW – integer; whether or not search engines should give juice to the link
   PAYED – integer; whether or not the featured link is paid for
   LINK_TYPE – integer;
   IPADDRESS – integer; ip address of link submitter
   DOMAIN – string;
   OTHER_INFO – string;
   META_KEYWORDS – string; meta keywords for link detail page
   META_DESCRIPTION – string; meta description for link detail page
   RECPR_EXPIRED – date; when the reciprocal link is no longer valid
$featuredlinks – 2D array; same as $feat_links
$have_search_results – integer; 0=no search results, 1=found search results
$hitlessOptions – array; used in advanced search; fields:
   0 – string; At Least
   1 – string; At Most
$imagehash – string; captcha hash; used for comparison purposes
$img_verification_error – boolean; true=captcha did not match, false=captcha matched
$InfoLimit – integer; remaining character limit on author’s info field
$languages – array; list of accepted languages; look in your /lang directory
$lart – integer; 1=latest articles available
$latest_art – 2D array; list of latest articles; same fields as $articles with additional field:
   DAT – date; DATE_ADDED in the format of abbreviated month followed by zero-filled date (e.g. Jan 01 through Dec 31)
$link_id_error – string; error message for invalid reciprocal or regular link
LINK_TYPE – integer;
$links – 2D array; list of links; same fields as $featuredlinks
$list – string; list filter name: latestlinks, latest, toplinks, top, latestarticles
$list_articles – 2D array; list of articles found in search results; same fields as $articles
$list_cat – 2D array; list of categories found in search results; same fields as $categs
$load_Javascript – integer; 0=do not load javascript, 1=load javascript
$locationOptions – array; looks like page headings; fields:
   links – string; Links
   articles – string; Articles
   categories – string; Categories
$logged_comment – integer; 1=user is logged in
$logged_rating – integer; 1=user is logged in
$mainCategs – 2D array; list of categories seen on front page; same fields as $categs
$maincontent – string; main page text, may be the tagline
$MetaAuthor – string; content for the meta author tag
$MetaCopyright – string; content for the meta copyright tag
$MetaDescription – string; content for the meta description tag
$MetaDescriptionLimit – integer; difference between the max meta description length and actual meta description length or the max meta description length if the actual meta description length is greater
$MetaKeywords – string; content for the meta keywords tag
$MetaRobots – string; content for the meta robots tag
$no_permission – boolean; true=user does not have access
$p – integer; current page number plus 1
$pages – 2D array; list of pages created in admin; fields
   ID – integer; unique page id
   NAME – string; page name
   SEO_NAME – string; page seo name
   CONTENT – string; page content
   STATUS – integer; page visibility
   PRIVACY – integer;
   PLACEMENT – integer; where in the main menu the page link should appear
   SHOW_IN_MENU – integer; whether the link should appear in the main menu
   DATE_ADDED – date; when page was added
   DATE_MODIFIED – date; when page was last modified
   META_KEYWORDS – string; meta keywords for page
   META_DESCRIPTION – string; meta description for page
$parentID – integer; a category’s parent ID
$password_recovered – integer; 1=password update successful, 0=password update unsuccessful
$path – array; administrative data for current page; fields:
   ID – integer;
   TITLE – string; page heading
   TITLE_URL – string;
   DESCRIPTION – string; short page description
$PAYMENT – array; payment data; fields:
   ID – integer; payment id
   LINK_ID – integer; id for link to be paid for
   IPADDRESS – string; ip address of payer
   QUANTITY – integer; tally of months(?)
   AMOUNT – float; cost per month(?)
   TOTAL – float; total cost
   UM – integer;
   PAY_DATE – date; current date and time
   CONFIRMED – integer;
   SUBSCRIBED – integer; subscription to newsletter?
$payment_um – ?
$posted – boolean;
$price – array; prices for each link; fields:
   featured – integer; price of featured link
   normal – integer; price of normal link
   free – integer; 0
   reciprocal – integer; price of reciprocal link
$printSearchPage – string; results=search results, form=advanced search form
$profileUpdate – string; yes=profile updated, no=profile not updated
$prurl – string; current url
$quantity – integer; number of months(?) the payment is for
$random_link – array; info for random link; same fields as $feat_links
$rating_disabled – string; disabled=rating disabled
$ratingError – string; error message for invalid rating
$ratings_on – integer; 0=ratings disabled for articles, 1=ratings enabled for articles
$recpr_required – integer; determines if reciprocal link is required for link submission
$regular_user_details – array; info about the logged in user; fields:
   ID – integer; user id
   LOGIN – string; user login
   NAME – string; user name
   EMAIL – string; user email
$regularlinks – 2D array; list of non-featured links; same fields as $feat_links
$remove_article – integer;
$remove_link – integer;
$review_article – integer;
$review_link – integer;
$rules – string; submission guidelines
$scriptname – string; current php file
$search – 2D array; list of search results for either category or articles
$search_article – string; content from search_article.tpl
$search_category – string; content from search_category.tpl
$search_terms – 2D array; same as $search
$searchquery – array; search parameters
$secondBanCheck – integer; 0=listed in ban table, 1=not listed in ban table
$send_password – integer; 1=on send password page
$ShowReciprField – integer; 0=hide reciprocal field, 1=show reciprocal field
SITE_NAME – string; web site name
$sort – string; sort parameter abbreviation
$sortbyOptions – array; names of sort options; fields:
   relevancy – string; Relevancy
   title – string; Title
   hits – string; Hits
   category – string; Category
$sortorderOptions – array; names of sort directions; fields:
   desc – string; Descending Order
   asc – string; Ascending Order
$sql_error – string; database error message
$StopLinkHits – integer; 0=enable link hit talley, 1=disable link hit tally
$SubLength – integer; length of subscription
$subscribe – integer; 0=did not subscribe, 1=subscribed
$SubscribeOptions – array; subscribe options; fields:
   0 – string; No
   1 – string; Yes
$Subscription – array; subscription info; fields:
   UM – string; Month, Year, Lifetime
   PERIOD – integer;
$SubscriptionEnabled – 0=user subscription disabled, 1=user subscription enabled
$SubscriptionF – array; fields same as $Subscrition
$SubscriptionN – array; fields same as $Subscrition
$SubscriptionPeriod – integer; length of subscription time
$SubscriptionR – array; fields same as $Subscrition
$SubscriptionUm – string; name of subscription time
$thank_you – integer; 1=display thank you message
$title – string; path title
$title_prefix – string; path title
$titleonlyOptions – array; title search options; fields:
   0 – string; Search All Fields
   1 – string; Search Titles Only
$uid – integer; user id
$url – string; a url
$user_edit – integer; 1=on the edit page
$user_registration – integer; 1=on the register page
$useRTE – integer; 1=use rich text editor
VERSION – PHPLinkDirectory version number
$wrong_user_details – integer; 1=wrong details for user profile
$yesno – array; yes/no options; fields:
   0 – string; No
   1 – string; Yes


PHPLD Template Tutorial – Part 2

The template files from Part 1 are written in a combination of HTML and Smarty. The Smarty engine takes variables assigned in the PHP code, interprets the data and spits out the web page; makes web development easier when the layout is separated from the coding.

I am working with PHPld v3.3 and it uses Smarty v2.6. The documentation can be found on Smarty’s website.

Here is a quick rundown of things you would see in the PHPld templates. All Smarty syntax begin and end with curly brackets. Content passed in from the PHP code to Smarty begin with a dollar sign.

{* *}
comments; does not appear in the source once the site is live

{if conditional} {/if}
{if conditional} {else} {/if}
{if conditional} {elseif conditional} {else} {/if}
a conditional statement; the ultimate philosophical question in code form: if something is true then you do this else if something else is true you do this else you do this if everything is false

to use constants defined in the PHP code, you need to prepend it with ‘$smarty.const.’

{include file="path/to/template.tpl" link="$variable"}
takes another template and drops it into the current template; optional link used to send variables in to be used by the included template

variable modifiers; modifies the format of the variable, make it upper case, make it lower case, trim off whitespace, etc

{php} {/php}
in some rare cases you may need to put PHP code in the template itself; but it’s frowned upon because the design and code should be kept separate

{literal} {/literal}
anything between the literal tags will not be interpreted by the smarty engine; mainly used for javascript such as google analytics or google adsense

{foreach from=$array key=$k item=$v} {/foreach}
loops through an array; example array in PHP would be $array = array("first"=>"John", "last"=>"Doe");; you would assign the PHP array to a Smarty variable and use foreach to loop through the array; on the first pass, $k = “first” and $v = “John”, on the second pass, $k = “last” and $v = “Doe”; used to display lists like the categories, links or articles

{assign var="variable name" value="variable value"}
assigns a value to a variable to be used later in the template

Example of Conditionals
{if condition1 and condition2} {/if}
if both condition1 and condition2 evaluate to true then execute the lines in-between

{if condition1 or condition2} {/if}
if one of the conditions evaluate to true then execute the lines in-between

{if value1 gt value2} {/if}
if value1 is greater than value2 then execute the lines in-between

{if value1 lt value2} {/if}
if value1 is less than value2 then execute the lines in-between

{if value1 eq value2} {/if}
if value1 is equal to value2 then execute the lines in-between

Example of Variable Modifiers

Strips double spaces, newlines and tabs with a single space by default or with a string entered after the colon

Encodes non-alphanumeric characters; defaults to HTML

You might see this in the code; trim is not a Smarty thing though, it’s a PHP function; it removes the white space before and after the variable

These are just a few of the ones I spotted doing a quick once over of the template files. There are many other commands available to review at Smarty’s website and probably a couple obscure ones I’ve missed in the templates. But, the above are the basics needed to get you where you want to go.


PHPLD Template Tutorial – Part 1

First, we look at the directory structure of a template and what each template file do. Each PHPld template generally contains the same files. I am not sure what some of the template files do though; they are probably for the pay-for-links version.

TemplateName/ – name of your template

images/ – store images
style/ – store css scripts
add_reciprocal.tpl –
article.tpl – article content page
article_search.tpl – article listing on search pages
articlelink.tpl – individual link block on browse pages
author.tpl – author profile page
banned_submit.tpl – user banned from submitting links message
category_search.tpl – category listing on search pages
category_select.tpl –
category_select_article.tpl –
category_tree.tpl –
contact.tpl – contact us page
detail.tpl – link detail page
footer.tpl – footer module
header.tpl – header module
index.html – unauthorized access page
left_side.tpl – left column content
link.tpl – listing of links in search pages
login.tpl – login form module
main.tpl – main layout of browse pages
page.tpl – not sure
pagerank.tpl – not sure
payment.tpl – not sure
paypal.tpl – not sure
profile.tpl – registration and account pages
readme.txt – template info
right_side.tpl – right column content
rss2.tpl – rss page
rules.tpl – article submission rules
screenshot.png – screenshot seen in admin
search.tpl – advanced search page
submit.tpl – link submit form
submit_article.tpl – article submit form
top_bar.tpl – menu
unauthorized.tpl – error messages