
Damon
Staff
/ Moderator

Sep 16, 2005, 5:10 PM
Post #1 of 18
(21612 views)
Shortcut
|
Tutorial: Creating a "View all articles by Author" link
|
Can't Post
|
|
Hi, By making some small changes to your templates and using Article Manager's search engine, you can have a link on your articles that will show all of that author's articles. To make it even easier to try out, I have attached the templates with the modifications already made. Update: Steps 1 and 2 are optional. These two steps were included so that there a consistent authors name entered to return search results with (the authors name is entered the same every time and not accidently left blank). Thanks to glevine for pointing this out. The attached templates below include all the steps. Step 1: In the Setup Options > General go to the Article Fields section and disable art_field1 by unchecking the enabled checkbox beside it. This article field will still be used but hard coded into interface templates in the next step. Step 2: Edit the create/edit article interface templates to hard code the authors field (art_field1) so that is auto-filled with the "Created by" name. This is the authors “Full Name” as entered in the Setup Options > Login Accounts section of Article Manager. Open the templates/interface/_art_menus.html template. Right after <!-- /templatecell : art_type_options --> add the following: <tr> <td><br><font style="font-size: 12px;" face="arial,sans-serif">Author </font></td> <td><br><input name="spare1" value="$created_by$" size="50" type="text"></td> </tr> Next open the templates/interface/_writer_menus.html template. Right after <!-- /templatecell : art_type_options --> add the following: <tr> <td><br><font style="font-size: 12px;" face="arial, sans-serif">Author </font></td> <td><br><input name="spare1" value="$created_by$" size="50" type="text"></td> </tr> If you don't want the author field to be editable by the writer (but still customizable by any editor or admin) then add this code to hide the field: <input name="spare1" value="$created_by$" size="50" type="hidden"> Step 3: To include a link to "View all articles by Author" on the full article page, open the /templates/article/default.html template and add (right after the Printer friendly page link) the following: <script type="text/javascript"> <!-- if ('$art_field1_je$') { document.write('View all articles by <a href="$url_search$?fields=art_field1&keyword=$art_field1$&template=index/articles_by_author_results.html">$art_field1$</a><br>'); } --> </script> <noscript> </noscript> The javascript will remove the link entirely if the author field is blank. Also replace: with this: <script type="text/javascript"> <!-- if ('$art_field1_je$') { document.write('By $art_field1$<Br>'); } --> </script> <noscript> </noscript> Again, the text "By" will be removed if the author field is left blank. Note: Now that the author field is auto-filled with the authors name, if you edit the field to be blank or display something else, this change will need to be made every time the article is edited. Step 4: The last step is to create a customized search result template to display all the authors articles. Open the /templates/search/search_results.html template. Save as it as /templates/index/articles_by_author_results.html. Change the title from: <title>Search Results</title> to this: <title>Articles by $in_keyword$</title> Replace this: <span class="header_breadcrumb">SEARCH RESULTS</span> with this: <span class="header_breadcrumb">Articles by $in_keyword$</span> In the articles by author search results, the $in_keyword$ placeholder will now be replaced with the authors name. The following templates with the above changes already made are attached as a zip file to this post to make trying this out even easier: /templates/interface/_art_menus.html /templates/interface/_writer_menus.html /templates/index/articles_by_author_results.html /templates/article/default.html Note: Before overwriting or customizing any of your templates, always make a backup copy.
If you try this out and use it on your site, I would be interested to see how it works out. --------------------------------------------------- Cheers Damon Edis interactivetools.com Hire me! Save time by getting our experts to help with your project. http://www.interactivetools.com/consulting/
(This post was edited by Damon on Jan 23, 2006, 3:25 PM)
|