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!
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.
@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 - 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, 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!
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.