by Eric Barnes
Smarty Templates include a whole host of features and in the post I will go over some Smarty conditional statements. Conditionals are basically a way for you to selectively show certain things based on some value.
Lets say for instance that you only want to display advertising to people visiting your site that are not logged in. This way it would give people that take the extra time to register an incentive. So if we write this out it would look something like this: “If you are a guest then show ads”.
To convert this to a Smarty conditional then we could do this:
{if $smarty.session.userlevel == 5} put your ad code {/if}
What this does is check the users session and if the userlevel is 5 (which by default is the guest user group) then show your add code.
Now that we have the basics lets get into a more complex conditional statement. For this one lets say: “If you are logged in then display a greeting. If not then display a generic welcome message”.
This would be written as:
{if $smarty.session.username<>” || $smarty.cookies.username<>“”}
Welcome {$smarty.session.username}
{else}
Welcome to our site. Why not join?
{/if}
The first part says if they are logged in and the username is not blank then display “Welcome Name”. Next if that condition does not run then display the else. “Welcome to our site….”.
I hope this helps you better understand Smarty conditional statements.
References
by Eric Barnes
Inside the administration of v4 we added a new check to prevent people from making post requests to your administration unless it comes from your domain name. This check was added as a security feature to prevent trying to bypass any forms. Although this was added for safety you can by pass it by adding this to the connections/classifieds.php file:
define('NO_REFERRER_CHECK', TRUE);
by Eric Barnes
Have you ever wanted to move your site to a new domain or to a new hosting provider? If so or if you plan to in the future then I recommend visiting this Google Blog Post that is a best practices guide to moving your site.
by Eric Barnes
One new feature added to the administration in 68 Classifieds v4 was access keys for navigation. Here is a list of the access keys currently available:
An access key or accesskey allows a computer user to immediately jump to a specific part of a web page via the keyboard.
- Alt + D - Dashboard
- Alt + H - Home
- Alt + F - Support Forums
- Alt + L - Listings
- Alt + O - Orders
- Alt + U - Users
- Alt + C - Categories
- Alt + P - Payment
- Alt + S - Settings
From Wikipedia
In most web browsers, the user does this by pressing Alt (on PC) or Ctrl (on Mac) simultaneously with the appropriate character on the keyboard. In Opera, the user presses ⇧ Shift+Esc followed by the access key (without Alt). In Mozilla Firefox 2.0 the access key keyboard combination has changed to Alt + ⇧ Shift (still configurable via about:config), while in Amaya, the preferences allow the user the option of choosing Ctrl or Alt. In Konqueror on Linux, The Ctrl key is pressed and released, and then the access key is pressed.
Whilst Mozilla and Firefox will execute the corresponding links immediately on the press of the access key, IE will just focus on the link and require ↵ Enter to be pressed in order to activate the link. If multiple identical access keys are assigned within the same document, IE will tab through them on each keypress (IE will tab backwards if ⇧ Shift will be pressed as well). This way, links can be logically grouped in various access key rings for easier navigation. IE 4.0 did only support letters of the English alphabet as accesskeys. Firefox 2.0 will activate the last of a group of links assigned the same accesskey.
by Eric Barnes
Most web hosts will give you access to manage your database through a script named phpmyadmin. In this tutorial I will go through the steps to make a backup of your database.
Read the rest of this entry »