Quoting the Famous and Infamous
Now, this really isn't going to address attribution and copyright issues -- you know about that, anyway.
The Quotes module is nice, but I wanted to put more STUFF into the quote displays, not just a quote and an author. After tinkering, I discovered that it is perfectly OK to put HTML into the quote edit field, so I created a set of css definitions, collected a set of quotes, wrote a Perl script to format them for me, and a template for creating those files specifically to match the ORP environment.
Feel free to use them. You'll need to install Perl (free), and use the Perl Package Manager to grab the IO and String packages (if they don't load with the basic installation), but that's not too tough. The script that produces the files has a few recognizable constants that you might have to change, but that should be fairly apparent if you look. As delivered below, the script expects to find the files "Revised59.txt" (the quotes, in a tab-separated format produced by Excel) and "QuoteFileTemplate.html" (containing a specification of what data to put into what file). It also expects to find a set of pictures in a parallel folder referenced as "../Pictures", and finally a local folder "Quotes" (into which it will place the resulting files).
To get started, download the .zip file and expand it where you find convenient. After you install Perl, double-click on the script and it should operate successfully. If not, open a command prompt window and run it from there to see any errors that appear.
The pictures should be uploaded, using your file manager or SSH client, to "~/sites/default/files/quotepics" (the "~" stands for your home folder on the website). You can certainly put them elsewhere, if you like, but then change the template file to reflect that location change.
Now, the QuoteFileTemplate.HTML file is a little obtuse, but it will make a little more sense after this:
- The script uses the template to determine what to output to the various files. Each line of the template is essentially a command, and each template command is executed for every quote in the text file, one at a time.
- The fields of each template line are separated by TAB characters. The fields are:
- <FileID>, the identifier of the output file affected by the command.
- <Function>, either "File" (to close an old file, and open a new one) and "Template" (an output generating line)
- <Change>, telling the script to activate the line when a particular column from the quote file has changed. Those column identifiers are listed below.
- <Control>, telling the script to be sure certain fields actually exist before outputting any data for that template line, and
- <Data>, the actual html structure to interpret and output.
- The template lines contain replacement tags prefaced by "$$". The script looks for these tags, and replaces them with data from the quote file. The fields can also be used in the Change and Control fields, although it might not prove useful to use most combinations. The fields are:
- $$Author, a composite of first and last name (quote file columns B & A)
- $$_Author, the author name, with blanks replaced by "_" (underscore).
- $$AuthIdent, identification information about the author (a one-line bio) (quote file column C)
- $$QuoteNum, identifies the quotes by number, starting with 0001 (4 digits, zero-filled).
- $$Quote, the full quote (quote file columns D & E)
- $$Citation, the source reference for the quote (quote file column F).
- $$Image1, the name of the first image file to use for the quote display (column G)
- $$Image2, the name of the second image file to use for the quote (column H).
- The <Change> field can utilize $$Author, $$QuoteNum, $$Quote, $$Citation, and two special tags, s $$Begin and $$End, which will show "changed" for the first quote and last quote, respectively.
- The <Control> field can utilize $$Author, $$AuthIdent, $$QuoteNum, $$Quote, $$Citation, $$Image1, and $$Image2.
- Both <Change> and <Control> fields allow multiple tags. The fields are "true" if any of the tags meets the condition.
As an example, the template line
SQ Template $$QuoteNum $$Author$$Image1$$Image2 **BURP**
is interpretted this way: If the quote number has changed, and there is any content in the author, image1, or image2 fields, then output "**BURP** to the file identified as "SQ".
Oh, just play with it. Or ask me for help. Hey, it's free, and there are hundreds of quotes already compiled for you.
To upload the quotes like I have on the ORP and CCRP sites:
- Grab the custom CSS elements, and put them into an appropriate place so that Drupal can use them to format the text being displayed. You will probably need to edit them for your site construction.
- Paste the full contents of the created "AllQuotes.html" file into a new page, in SOURCE mode, and set the URL for that page to "AllQuotes".
- If you want an author index, create a block that is set to only display on the AllQuotes page (or other quote pages), and paste the full contents of AuthorIndex.html into that block, in SOURCE mode.
- TEST the display and link functions by grabbing a single quote, and creating a quote content item. Fill in the author in the single line provided for that, and paste the entire HTML-formatted quote into the edit window, in SOURCE mode. Fuss with things until you are satisfied it works, then delete the one test quote you created.
- Create a new quote item, and be careful! Paste the entire contents of QuoteLoad.txt into the SOURCE mode of the editor, double-check that the input format is unrestricted, verify that the quotes are NOT promoted to the front page, verify that your authorship is what you want, etc. Finally, be sure you check "import tab-separated....", so that the quote module will peel apart the text into the hundreds of individual items.
- If you heartily mess up, not to worry. Just delete all the quotes you just entered and start over. (See, THAT'S why you test with a single quote, or two or three, to start with). If you really do have to start over, I suggest the Drupal CMF module to help expunge the mess, because it allows you to do more quotes at a time.
*** Soon I will add an "NewItem" column to the process, so that adding quotes to the database will not require as much work. Keep watching.
Tom Harrison
- Printer-friendly version
- Login or register to post comments

