 | |  |
 |

Damon
Staff
/ Moderator

Sep 16, 2005, 5:10 PM
Post #1 of 18
(12533 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
(This post was edited by Damon on Jan 23, 2006, 3:25 PM)
|
|
Attachments:
|
templates.zip
(16.1 KB)
|
|
|  |
 |

glevine
User
Jan 24, 2006, 1:48 PM
Post #2 of 18
(10711 views)
Shortcut
|
|
Re: [Damon] Tutorial: Creating a "View all articles by Author" link
[In reply to]
|
Can't Post
|
|
In the event that you don't use steps 1 and 2 I thought I would post my solution for parsing author names. My articles can be written by any number of authors, so it was necessary for me to parse a string of authors (from 1 to n) and create links for each. My author strings could look like any of the following: John Doe John Doe and Jane Doe John Doe, Jane Doe, + ... +, Jim Doe and Jen Doe Note: You will have to make some changes to the code in order to make this work for you if you don't build your byline exactly the same as I do. The following code will parse all authors and create links for each:
<script type="text/javascript"><!-- if( '$art_field1_je$' ) { var array1 = '$art_field1_je$'.split( ' and ' ); //last author in array[1]; all others in array[0] var array2 = array1[0].split( ', ' ); //split all authors other than the last author into array2 if( array1.length == 1 ) //only 1 author document.write( 'By <a href="$url_search$?fields=art_field1&keyword=$art_field1$&template=search/articles_by_author_results.html">$art_field1_je$</a><br/>'); else //more than 1 author { var searchstr = ''; //stores the query string if( array2.length > 1 ) //there are 3 or more authors { for( var i = 0; i < array2.length; i++ )//for each author before the last author { if( i == 0 ) //add the author name to the query string without '&' before the name because this is the first author searchstr = array2; else //add the author name to the query string with '&' before the name because this is author #2 through the 2nd to last author searchstr += ( '&' + array2 ); } searchstr += ( '&' + array1[array1.length-1] ); //add the last author name to the query string with '&' before the name } else //there are 2 authors searchstr = array1[0] + '&' + array1[1]; //add the 2 author names to the query string with '&' between them //each name will have it's own link var array3 = searchstr.split( '&' ); //split the query string so that each author name is stored in its own index document.write( 'By ' ); for( var j = 0; j < array3.length-1; j++ ) //for each author before the last author { if( j != array3.length-2 ) //write the search link for the author followed by a comma and a space because there is another author following this one document.write( '<a href="$url_search$?fields=art_field1&keyword=' + array3[j] + '&template=search/articles_by_author_results.html">' + array3[j] + '</a>, ' ); else //write the search link for the 2nd to last author followed by ' and ' because there is only 1 more author following this one document.write( '<a href="$url_search$?fields=art_field1&keyword=' + array3[j] + '&template=search/articles_by_author_results.html">' + array3[j] + '</a> and ' ); } //write the search link for the last author document.write( '<a href="$url_search$?fields=art_field1&keyword=' + array3[array3.length-1] +'&template=search/articles_by_author_results.html">' + array3[array3.length-1] + '</a><br/>' ); } } // --></script> <noscript>$art_field1$</noscript>
(This post was edited by glevine on Jan 24, 2006, 1:49 PM)
|
|
|  |
 |

MikeB
Staff
/ Moderator

Jan 25, 2006, 1:14 PM
Post #3 of 18
(10681 views)
Shortcut
|
|
Re: [glevine] Tutorial: Creating a "View all articles by Author" link
[In reply to]
|
Can't Post
|
|
Hi glevine, Thanks for the post! :) This looks great and I'm sure that this will be helpful for anyone who is organizing their site in a similar way. I tried playing around with this here and I actually ran into a bit of a problem with the commas not separating properly when the author names were passed to the search query. I made a quick change and it looks like everything is up and running now. I think the problem had to do with the forum replacing the [i] tag with italics. I just changed this piece of code: searchstr = array2; else //add the author name to the query string with '&' before the name because this is author #2 through the 2nd to last author searchstr += ( '&' + array2 ); To look like this: searchstr = array2[i]; else //add the author name to the query string with '&' before the name because this is author #2 through the 2nd to last author searchstr += ( '&' + array2[i] ); You'll notice I just changed "array2" to "array2[i]" in a couple of places so just the individual names will be passed, as it looks like these two attributes were removed in the post. Thanks again for this great addition to Damon's tutorial and if you have any other questions or comments, just let me know! :) Cheers, Mike Briggs - Product Specialist support@interactivetools.com
Hire me! Save time by getting our experts to help with your project. Template changes, advanced features, full integration, whatever you need. Whether you need one hour or fifty, get it done fast with Priority Consulting.
|
|
|  |
 |

glevine
User
Jan 25, 2006, 2:23 PM
Post #4 of 18
(10675 views)
Shortcut
|
|
Re: [MikeB] Tutorial: Creating a "View all articles by Author" link
[In reply to]
|
Can't Post
|
|
Thanks, I knew there was a reason my code was italicized but I couldn't figure it out and gave up rather quickly. I didn't realize a piece of my code was getting misinterpreted by the forum.
|
|
|  |
 |

jmueller0823
User
Mar 2, 2006, 3:32 PM
Post #5 of 18
(10270 views)
Shortcut
|
|
Re: [glevine] Tutorial: Creating a "View all articles by Author" link
[In reply to]
|
Can't Post
|
|
Does anyone have a working example? Jim g r o w t h t r a c dot c o m Life Changing Resources for Your Marriage
|
|
|  |
 |

jmueller0823
User
Mar 4, 2006, 5:56 AM
Post #7 of 18
(10202 views)
Shortcut
|
|
Re: [jmueller0823] Tutorial: Creating a "View all articles by Author" link
[In reply to]
|
Can't Post
|
|
glevine My compliments-- very clean, attractive site. -- Is what I'm seeing on your site the JS implementation? I'm trying to understand how your implementation is different from the initial idea presented in the first message. Please explain. Thanks. Jim g r o w t h t r a c dot c o m Life Changing Resources for Your Marriage
|
|
|  |
 |

glevine
User
Mar 4, 2006, 11:17 AM
Post #8 of 18
(10196 views)
Shortcut
|
|
Re: [jmueller0823] Tutorial: Creating a "View all articles by Author" link
[In reply to]
|
Can't Post
|
|
Thanks for the compliment. Yes it is the JS implementation. If you take a look at this thread you will notice that I was the one who developed the alternative pieces to the original implementation. I did my best to describe all of my choices, but if anything is unclear let me know and I'll try to do better.
|
|
|  |
 |

jmueller0823
User
Mar 4, 2006, 11:23 AM
Post #9 of 18
(10193 views)
Shortcut
|
|
Re: [glevine] Tutorial: Creating a "View all articles by Author" link
[In reply to]
|
Can't Post
|
|
Okay. I got it. Here's a new idea/question: Are you (or is anyone) displaying a list of authors? Many readers have favorite authors. They could view this list, and click over to the "articles by author" list ... Thinking this could be a simple search & template based on author name. But... is it possible to display a unique list of author names? Jim g r o w t h t r a c dot c o m Life Changing Resources for Your Marriage
(This post was edited by jmueller0823 on Mar 4, 2006, 11:26 AM)
|
|
|  |
 |

glevine
User
Mar 4, 2006, 11:59 AM
Post #10 of 18
(10187 views)
Shortcut
|
|
Re: [jmueller0823] Tutorial: Creating a "View all articles by Author" link
[In reply to]
|
Can't Post
|
|
I do use a list of authors in the sense that when multiple authors contributed to a story then all of their names will be listed and linked individually, separated by commas. Correct me if I'm wrong but I think what you are asking about is how to include a list of any number of authors to be displayed as a "Featured Columnists," or something along those lines. If that is true then you would just need to build a table with all of your featured authors and link them exactly as you would with the JS implementation, except that no JS is necessary. So each author's link would look like this:
<a href="http://www.yoursite.com/artman/exec/search.cgi?fields=art_field1&keyword=John Doe&template=search/articles_by_author_results.html">Jon Doe</a> I would put that in an SSI so you can display it on every page and easily modify it as needed.
(This post was edited by glevine on Mar 4, 2006, 11:59 AM)
|
|
|  |
 |

jmueller0823
User
Mar 4, 2006, 12:36 PM
Post #11 of 18
(10180 views)
Shortcut
|
|
Re: [glevine] Tutorial: Creating a "View all articles by Author" link
[In reply to]
|
Can't Post
|
|
I think you're close. What I'm thinking is that AM would dynamically create the Author list. I don't want to create a static 'list'. Jim g r o w t h t r a c dot c o m Life Changing Resources for Your Marriage
|
|
|  |
 |

glevine
User
Mar 4, 2006, 12:44 PM
Post #12 of 18
(10179 views)
Shortcut
|
|
Re: [jmueller0823] Tutorial: Creating a "View all articles by Author" link
[In reply to]
|
Can't Post
|
|
Okay, I think you'll have to wait to hear from someone at IT. I don't think it's possible to have a dynamic list of authors, but they will know better than me. You could hack the system and develop this tool yourself, but that seems like a lot of work for something so small. Maybe they would add it to the requests list.
|
|
|  |
 |

jmueller0823
User
Mar 4, 2006, 12:50 PM
Post #13 of 18
(10177 views)
Shortcut
|
|
Re: [glevine] Tutorial: Creating a "View all articles by Author" link
[In reply to]
|
Can't Post
|
|
Well, I know I can do a list of Author names. That is possible. The catch is making a unique list (no duplicate names). Jim g r o w t h t r a c dot c o m Life Changing Resources for Your Marriage
|
|
|  |
 |

Mike4172
User
Mar 5, 2006, 1:01 PM
Post #14 of 18
(10128 views)
Shortcut
|
|
Re: [jmueller0823] Tutorial: Creating a "View all articles by Author" link
[In reply to]
|
Can't Post
|
|
Hmm so your desired output would be something like: John Smith (5 Article(s)) If that's what your wanting when the MYSQL version of AM comes out that would be rather simple to do. The ability to manipulate data when its stored in a DB as oppose to the flat file system is rather easy/basic. One of the many advantages you'll see when the new AM is released. Regards, Michael NEW!Logo and Website Design Auto Post Date and Expiration GoForum 2.02 http://www.amscripts.net SKYPE - michael.amscripts
(This post was edited by Mike4172 on Mar 5, 2006, 1:01 PM)
|
|
|  |
 |

ross
Staff
/ Moderator

Mar 6, 2006, 9:13 AM
Post #15 of 18
(10089 views)
Shortcut
|
|
Re: [jmueller0823] Tutorial: Creating a "View all articles by Author" link
[In reply to]
|
Can't Post
|
|
Hi Jim. Thanks for posting! With the current Article Manager it is actually possible to create a list that has the number of articles next to each author; however, it would be done with SSI calls to the search script. This is going to slow things down on the page because for each author you have there will be a search running. If you want to try it out though, I can put a walk through for you . ----------------------------------------------------------- Cheers, Ross Fairbairn - Product Specialist support@interactivetools.com
Hire me! Save time by getting our experts to help with your project. Template changes, advanced features, full integration, whatever you need. Whether you need one hour or fifty, get it done fast with Priority Consulting.
|
|
|  |
 |

jmueller0823
User
Mar 6, 2006, 9:23 AM
Post #16 of 18
(10087 views)
Shortcut
|
|
Re: [ross] Tutorial: Creating a "View all articles by Author" link
[In reply to]
|
Can't Post
|
|
Hi Ross Thanks. I may need to re-define my initial request. I need AM to produce a list of authors. This needs to be a unique list-- no duplicates. I am able to display an author list; the question is how to prevent dupes. Jim g r o w t h t r a c dot c o m Life Changing Resources for Your Marriage
|
|
|  |
 |

ross
Staff
/ Moderator

Mar 6, 2006, 12:59 PM
Post #17 of 18
(10080 views)
Shortcut
|
|
Re: [jmueller0823] Tutorial: Creating a "View all articles by Author" link
[In reply to]
|
Can't Post
|
|
Hi Jim. Creating a list of the authors without duplicating isn’t something I have seen done in Article Manager before. I would imagine you could use some JavaScript to keep track of things but that would go beyond my level of expertise. Does anyone else in the community have any suggestions on this one? It would be great if we could hear from you . ----------------------------------------------------------- Cheers, Ross Fairbairn - Product Specialist support@interactivetools.com
Hire me! Save time by getting our experts to help with your project. Template changes, advanced features, full integration, whatever you need. Whether you need one hour or fifty, get it done fast with Priority Consulting.
|
|
|  |
 |

jmueller0823
User
Mar 6, 2006, 1:18 PM
Post #18 of 18
(10077 views)
Shortcut
|
|
Re: [ross] Tutorial: Creating a "View all articles by Author" link
[In reply to]
|
Can't Post
|
|
Ross Might be something I back-burner until the MySQL version releases... Jim g r o w t h t r a c dot c o m Life Changing Resources for Your Marriage
|
|
|  |
|