To provide another example of Lookup usage, if you are a photographer and you provide your clients with a passcode like jimsusanwedding11, they can enter that passcode in the box and get forwarded through to a gallery page called jimsusanwedding11.html on your website. In another example, you could use the Lookup stack to retrieve forms or PDF documents from an online cloud, based on the document reference number entered. Or if you provide customers with coupon codes, they can enter them in the box and get forwarded to a particular page on your website with special discounts listed.

Unlike many copy-and-paste javascript code snippets already available online, this stack does actually work in web browsers made after 1998! The lookup stack leverages some powerful PHP code and is both easy to setup and has plenty of customisable options to satisfy most users. Most importantly, it is easy for your customers to use, and a wrongly-typed passcode results in a customisable error message being displayed.

Important As mentioned already, this stack provides a low-security login system. Although passcodes and full page addresses are not presented in the source code, it would still be possible to 'guess' the page address and gain access to unencrypted pages or files. If you need a more robust login solution which physically encrypts pages, then consider something like Lockdown, WeaverBox or WeaverFM instead.


Examples

PDF document

Type example in the input box below and click download, to retrieve a secret PDF file.
In this example the path in the Lookup settings was set to https://stacks4stacks.s3.amazonaws.com/test/ and the file extension was set to .pdf. When you type the actual file name in the box above, it completes the URL and provides a link to the PDF file:

https://stacks4stacks.s3.amazonaws.com/test/lookup/example.pdf

Password box

Type secret in the input box below and click open.
This example uses the password input type, which is available for selection in the Lookup input type settings. Typed passcodes are entered in the form of a password, and are obfuscated by dots. Additionally if the web browser has any keychain or password utilities available (like 1Password), the user will be prompted to save the passcode. When you type the word 'secret' in the box above, it completes the URL and provides a link to the file:

https://stacks4stacks.s3.amazonaws.com/test/lookup/secret.html

Photographs

Type mypicture.jpg or mypicture.gif in the box below and click view image.
In this example, the file extension setting in the Lookup settings has been left blank, so an end user can decide themselves whether to open the JPG or GIF version of the image. When you type the word 'mypicture.jpg' or 'mypicture.gif' in the box above, it completes the URL and provides a link to the image:

https://stacks4stacks.s3.amazonaws.com/test/lookup/mypicture.jpg
or
https://stacks4stacks.s3.amazonaws.com/test/lookup/
mypicture.gif

Coupon Codes

Type discount16 in the box below.
If a successful discount code is entered, the customer will get redirected to the discount16 page on your website. As like previous examples, the passcode discount16 completes the URL and redirects a user to that particular resource:

https://stacks4stacks.s3.amazonaws.com/test/lookup/discount16.html

As this page demonstrates, you can safely use multiple Lookup stacks on a single page. The Lookup stack is also compatible with the @import function in PlusKit, so you can import Lookup stacks into non-stack pages. Some people prefer to use browser defaults for styling forms in web pages, however several dozen settings are included for you to apply custom styling to both the input field and submit button. Options also exist to change the input box placeholder text and the submit button title. Although the Lookup stack uses PHP code, the page hosting the form field and submit button can be left as a regular HTML page, if you prefer. If you opt to have the input box displayed as a password field, keychain software like 1Password will offer to save the passcode for you.

Setup

  1. Once installed, drag and drop a Lookup stack into your page
  2. In the Base URL box, enter the initial URL like http://www.example.com/folder/
  3. If a file extension, forward-slash character or other content needs to be appended after the value a user types in the box, then enter this in the extension box.
  4. In the Input Type menu, choose whether to use a standard text box ot a password box. Both work in a similar way, except typed characters are replaced with dots, when using the password box option.
  5. The input box placeholder text and the submit button text can both be changed, if required.
  6. Optionally, you can change the colour and style of both the input box and submit button, using the settings provided

Customising the error message

If a user mistypes the wrong passcode, a simple error message is displayed informing them of their mistake and providing a "try again" button. This message gets generated by the PHP code, based on whether a matching URL can be found or not. To edit the error message, go to Finder and click Go > Go to folder from the menu. In the window that opens, type (or paste) the following:

~/Library/Application Support/RapidWeaver/Stacks/
Then click Go.

In the new window that opens, right-click on your S4S-Lookup.stack file, and select Show Package Files. Click on Contents, then click on Resources. Open the process.php file in your favourite code editor, and scroll down towards the bottom, where you will see a comment and the existing HTML error code. Change the text to whatever you want and enter custom code or scripts. You can add additional text, links, graphics and CSS. Save the file when done and restart RapidWeaver for the changes to take place in your stack. If you have problems finding or customising this file, please get in contact. Unfortunately Stacks does not currently allow us to write code or styled content into an asset like process.php, so the editing has to be done manaully for now.

System Requirements

This stack requires a web server with support for PHP5 and cURL. Most hosts do support these things and will be able to confirm if you contact them. You will not be able to preview the Lookup stack in RapidWeaver. But if you publish the website or view it in your sites folder (with PHP enabled) or in MAMP, you can test the Lookup stack offline. Because of the dependancy on PHP support, the Lookup stack will not work with MobileMe hosting and will likely fail on cheap hosts (these companies often use non-standard versions of PHP or charge extra to enable PHP as part of your hosting package). You are strongly advised to download and test the free demo version provided, before purchasing the Lookup stack. If you can't get the demo to work, then do not purchase this stack. It may be unsuitable for your needs.