We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Author links

How Do I?

andrew.reff's avatar
andrew.reff
26 posts
8 years ago
andrew.reff's avatar andrew.reff

Question if this is even possible without using an add-on or something …

Is it possible to use an author’s screen name or user name as opposed to using their id when trying to grab their link and set up an author page? Currently I have it working perfectly fine using the author id, however i was curious if it was possible to do this so the path was a little prettier;

Right now i’m getting - /blog/author/4 And would love if i could get something like - /blog/author/author.name

Any help is greatly appreciated. Thanks y’all!

       
Pedro Guimaraes's avatar
Pedro Guimaraes
170 posts
8 years ago
Pedro Guimaraes's avatar Pedro Guimaraes

I created a simple addon for this and it can be found here

Pick the correct segment # for where the author’s name will be in the URL. Usage:

{exp:channel:entries channel="articles" author_id="{exp:author_id:get_id  screen_name='{segment_2}'}{/exp:author_id:id}" parse="inward" limit=20" dynamic="no"}

Use the code below to generate URL friendly screen names:

<a href="/news/{exp:author_id:get_screen_name='{screen_name}'}">

The caveat is that the add on may have issues with a screen name that has non-url friendly characters, so I highly recommend setting the author’s screen name to alpha numeric only.

       
andrew.reff's avatar
andrew.reff
26 posts
8 years ago
andrew.reff's avatar andrew.reff

@pedro - whenever i plug the add-on in and use the suggested code above, I get a completely blank rendered page

This is what I am using;

{exp:channel:entries channel="blog" author_id="{exp:author_id:get_id  screen_name='{segment_3}'}{/exp:author_id:id}" parse="inward" limit=6" dynamic="no" paginate="bottom"}

For reference, here is the placement of the segment; https://SITENAME/blog/author/1

       
Pedro Guimaraes's avatar
Pedro Guimaraes
170 posts
8 years ago
Pedro Guimaraes's avatar Pedro Guimaraes

Shouldn’t the link be https://SITENAME/blog/author/author-screen-name-here ?

Maybe I’m missing something… 😊

       
andrew.reff's avatar
andrew.reff
26 posts
8 years ago
andrew.reff's avatar andrew.reff

@pedro - I was showing “https://SITENAME/blog/author/1” to show the reference of where the “author id” segment was, segment_3, to ensure I was using the correct segment. I wasn’t even able to get to “https://SITENAME/blog/author/author-screen-name-here” because when using the code below, it rendered a blank html page;

{exp:channel:entries channel="blog" author_id="{exp:author_id:get_id  screen_name='{segment_3}'}{/exp:author_id:id}" parse="inward" limit=6" dynamic="no" paginate="bottom"}
       
Pedro Guimaraes's avatar
Pedro Guimaraes
170 posts
8 years ago
Pedro Guimaraes's avatar Pedro Guimaraes

Tested this out on a couple sites and had no issues. Perhaps just have {exp:author_id:get_id screen_name='{segment_3}’}{/exp:author_id:id} in the template. It should return the author’s ID #.

       
andrew.reff's avatar
andrew.reff
26 posts
8 years ago
andrew.reff's avatar andrew.reff

@pedro, so let’s make sure for clarification, I am setting this up correctly;

Here is my existing code box;

{exp:channel:entries channel="blog" limit="6" paginate="bottom"} 
<a href="http://{path=%27blog/index%27}%22id=%22" class="{cf_column_size}">{category_name}</a></li>
     {/categories}          
   </ul>
   <a href="http://{url_title_path=blog/article}">_    <div class="listing-media"  url('{cf_list_banner}');"></div>_    <div class="listing-content">_     <h6>{entry_date format="%F %j, %Y"}</h6>_     <h3>{title}</h3>_     {cf_meta_description}_    </div>           _   </a>
   <div class="post-meta">
    <ul>
     <li class="author">By <a href="/blog/author/{author_id}">{member_name}</a></li>
    </ul>           
   </div>
   {if:elseif cf_media_type == 'blog-quote'}
   <a href="http://{url_title_path=blog/article}">_    <div class="listing-content">_     <blockquote>_      {cf_blog_quote}_      <small>{cf_blog_quote_author}</small>_     </blockquote>            _    </div>           _   </a>
   {if:else}
   {/if}
  </div>
 </div>       
</article>
{paginate}
<nav>
  {pagination_links}
 <ul id="pagination-page">
 {page}
   <li><a href="http://{pagination_url}" class="page-{pagination_page_number} {if current_page}active{/if}">{pagination_page_number}</a></li>
 {/page}
 </ul>        
  {/pagination_links}       
</nav>
{/paginate}
{/exp:channel:entries}

With your plugin, is the set up supposed to look more like this;

{exp:channel:entries channel="articles" author_id="{exp:author_id:get_id  screen_name='{segment_2}'}{/exp:author_id:id}" parse="inward" limit=20" dynamic="no"}
<a href="http://{path=%27blog/index%27}%22id=%22" class="{cf_column_size}">{category_name}</a></li>
     {/categories}          
   </ul>
   <a href="http://{url_title_path=blog/article}">_    <div class="listing-media"  url('{cf_list_banner}');"></div>_    <div class="listing-content">_     <h6>{entry_date format="%F %j, %Y"}</h6>_     <h3>{title}</h3>_     {cf_meta_description}_    </div>           _   </a>
   <div class="post-meta">
    <ul>
     <li class="author">By <a href="/blog/{exp:author_id:get_screen_name={screen_name}}">{member_name}</a></li>
    </ul>           
   </div>
   {if:elseif cf_media_type == 'blog-quote'}
   <a href="http://{url_title_path=blog/article}">_    <div class="listing-content">_     <blockquote>_      {cf_blog_quote}_      <small>{cf_blog_quote_author}</small>_     </blockquote>            _    </div>           _   </a>
   {if:else}
   {/if}
  </div>
 </div>       
</article>
{paginate}
<nav>
  {pagination_links}
 <ul id="pagination-page">
 {page}
   <li><a href="http://{pagination_url}" class="page-{pagination_page_number} {if current_page}active{/if}">{pagination_page_number}</a></li>
 {/page}
 </ul>        
  {/pagination_links}       
</nav>
{/paginate}
{/exp:channel:entries}

Please advise. Thank you!

       
andrew.reff's avatar
andrew.reff
26 posts
8 years ago
andrew.reff's avatar andrew.reff

Apologize how that code came through, i had it formatted and it become unformatted :(

Here is a html formatter i use to help format it so see it better; http://www.freeformatter.com/html-formatter.html

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.