ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Can I use backspace to trim {member_group}?

September 28, 2012 7:39pm

Subscribe [1]
  • #1 / Sep 28, 2012 7:39pm

    Rick Lecoat

    128 posts

    I want to display what type of member the author of a comment is; eg. “Joe Bloggs, Contributing writer”. But my member groups are named as plurals—so Joe is actually part of the member group “Contributing writers”. I had hoped to be able to use backspace to trim off the trailing ‘s’, but it sees that backspace is not allowed on that variable, since the result displayed in the rendered page changes from ‘Joe Bloggs, Contributing writers’ to ‘Joe Bloggs, {member_group backspace="1"}’.

    1. Can I achieve what I’m after (without renaming the member group, ideally), and
    2. The tags and variables for which we can use backspace seem to be a bit random and scattered all through the documentation; is there a way of ascertaining which variables and tags it is permitted to use Backspace on? (eg. a list of them?)

    Thanks as always;
    Rick

  • #2 / Oct 01, 2012 12:52pm

    Dan Decker

    7338 posts

    Hi Rick,

    Indeed, backspace is a parameter and generally, variables do not support parameters.

    2. The tags and variables for which we can use backspace seem to be a bit random and scattered all through the documentation; is there a way of ascertaining which variables and tags it is permitted to use Backspace on? (eg. a list of them?)

    As a rule, any tag or variable pair that iterates through a loop. Single instance variables like {member_group} won’t have a use for backspace.

    I’d really like to see your template code. Based on your post, I think you are using the comment module, which doesn’t list member_group as a variable.

    In the meantime, look over these add-ons that can strip bits from content.

    Cheers,

  • #3 / Oct 01, 2012 1:13pm

    Rick Lecoat

    128 posts

    I’d really like to see your template code. Based on your post, I think you are using the comment module, which doesn’t list member_group as a variable.

    Here’s my comments code:

    {exp:comment:entries sort="asc"}
     {if no_results}
     <div class="comment">
      <div class="entry_content">
       Be the first to comment on this article!
      </div>
     </div>
     {/if}
     <div class="comment">
      <div class="meta">
       {absolute_count}
      </div>
      <div class="entry_content">
       <strong>{name}</strong>, {exp:member:custom_profile_data member_id="{author_id}"}{member_group}{/exp:member:custom_profile_data}
    
       <span class="date">{comment_date format="%F %d, %Y"} at {comment_date format="%H"}:{comment_date format="%i"}</span>
       {comment}
      </div>
     </div>
    {/exp:comment:entries}

    As you can see, the member group is accessed from a member:custom_profile_data tag—that being itself nested within a comment:entries tag. Is that permissible? Because it definitely works!

    In the meantime I’ll have a look at those add-ons you suggested. Thanks.

  • #4 / Oct 01, 2012 2:01pm

    Rick Lecoat

    128 posts

    Hi Dan;

    None of those add-ons were quite right for me because they all deal with truncation after a specified number of words/characters. But Trimmer is a super lightweight plugin that does exactly what I need. Win!

    Could you just confirm for me that my code is okay? Many thanks.
    Rick

  • #5 / Oct 02, 2012 10:53am

    Dan Decker

    7338 posts

    Hey Rick,

    Thanks for the template code! Yup, looks good from here.

    Trimmer sounds like a treat, I’m glad you found a solution!

    If you need anything else, please let us know.

    Cheers,

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases