how to list authors of given type
  • I need to list all Blogers (type of registered user). Any solutions?
  • 6 Comments sorted by
  • Vote Up0Vote Down Jakub GórnickiJakub Górnicki
    Posts: 134Member, Administrator, Sourcefabric Team
    Hey Tomek, we need more details? Can you tell us how do you want to handle it and what should be the end result?
  • I need to list all authors from given section or type to show blogger list. Like
    {{list_authors type="blogger" }}
    or
    {{list_authors constraints="section is 10" }}
  • Hi Tomasz,

    a) There isn't anything like:
    {{ list_authors type="blogger" }}

    ... but Smile you can try something like:

    1) listing the list of articles within the whole publication
    2) within the list of articles, list article's authors
    3) validate whether the current author has type "blogger"

    NOTE: there will be duplicated authors (bloggers) as you are getting the list from articles and an author can be author of multiple articles. So, in order to get a list of unique authors, you have to do it by coding and there are different ways. Try storing authors in an array and remove duplicates from it.

    The code of the three steps explained above would be something like this:

    {{ list_articles ignore_issue="true" ignore_section="true" }}
    {{ list_article_authors }}
    {{ if $gimme->author->type == 'blogger' }}
    {{ $gimme->author->name }}<br />
    {{ /if }}
    {{ /list_article_authors }}
    {{ /list_articles }}

    b) There isn't anything like this neither:
    {{ list_authors constraints="section is 10" }}

    ... but, again you can achieve it by using the approach explained above with slight changes.

    {{ list_articles ignore_issue="true" constraints="section is 10" }}
    {{ list_article_authors }}
    {{ $gimme->author->name }}<br />
    {{ /list_article_authors }}
    {{ /list_articles }}

    NOTE: Again, you will get duplicated articles, but you already know how to work around it Smile

    We will provide more precise instructions in the template engine to achieve this kind of things, but as you can see in Newscoop the power of $gimme is real ! Smile

    Let us know if it works !

  • That would work but when there is a lot of content the amount of data from database will be huge. Maybe there is a way I can execute simple select from PHP?
  • working solution from me.

       {{ php }}
       $tab=array();
       {{/php}}            
    	{{ list_articles ignore_issue="true" }}
    			{{ list_article_authors }}
    
    
    {{ assign var="author_name" value=`$gimme->author->name` }}
    
    {{ php }}
    $author = $this->get_template_vars('author_name');
    if(in_array($author, $tab)){
    	$flag=0;
    }else{
    	$flag=1;
    	$tab[]=$author;
    }
    
    if($flag){
    
    {{ /php }}
      <!-- list -->
      		<div class="list_item">
    	
                                     {{$gimme->author->name}}
                 </div>
    	<!-- list -->		
    
    
    
    
    {{php}}
    }
    {{/php}}
    {{ /list_article_authors }}
    {{/list_articles}}
      
  • Vote Up0Vote Down Jakub GórnickiJakub Górnicki
    Posts: 134Member, Administrator, Sourcefabric Team
    Thanks Tomek!