1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Can I show a certain number of characters of a post?

Discussion in 'XenForo Questions and Support' started by Core Freedom, Oct 13, 2012.

  1. Core Freedom

    Core Freedom Well-Known Member

    Hi all, I'm having a bit of a challenge. I divided my forums into a 'free' and a 'paid' section just recently. And I understand that the 'paid' and now hidden section no longer gets picked up by Google. So visitors have dropped.

    Is there a way to show a certain number of characters or words of the first post in each thread to 'free' members but then make the rest for 'upgraded' members only?

    Right now I am showing the forum name and the thread title, but as soon as they click on the thread title it tells them that they must upgrade. I'd like them to see just a few sentences of the post before they make upgrade (and so that Google) can index that page.

    Can this be done?
     
  2. borbole

    borbole Well-Known Member

    Core Freedom likes this.
  3. James

    James Well-Known Member

    I don't have a test XenForo installation online to try it, but in the "post" template you might be able to create a conditional, such as:
    Code:
    <xen:if is="!{xen:helper ismemberof, $visitor, x}">
    {xen:helper snippet, $message, 20}
    <xen:else />
    $message
    </xen:if>
    
    "If user isn't a member of x, show 20 words, else, show full message".

    If I had a test install I'd try it myself!
     
    Core Freedom likes this.
  4. Core Freedom

    Core Freedom Well-Known Member

    Thank you both!

    I think I had originally installed this, Borbole, and I really liked it. For some reason I can't find it in the add-on list anymore. So the quest is about the extra modification. Is it possible to have the add-on functioning in the 'free' forum and show x-number of sentences and have it work modified in the 'paid' forum where it also shows x-number of sentences (simply so Google can pick it up) but then as, James is saying, the full post would show to paying members and prompt guest and free members to upgrade? Not a script writer so don't know if the snippet above would work. If not, are you able to write a mod for your add-on?
     
    borbole likes this.
  5. Core Freedom

    Core Freedom Well-Known Member

    Borbole, I installed the mod and I discovered that it does some funky thing of giving me an error page when there is a post with a poll. Your mod doesn't seem to work the moment there is a poll in the post, it won't even show the page but give an error page saying there is an internal configuration error (some white, blank page with black writing). I do quite a few polls in the free forum area, do you know of this being a problem and can it be fixed?
     
  6. James

    James Well-Known Member

    I managed to recreate this with a template edit:
    You need to change the conditional (the first red part) to the group(s) you want to see the full message, such as: {xen:helper ismemberof, $visitor, x, y, z}.

    You then need to change the 20 to the amount of characters you wish the other users to see.

    This is in the message template by the way.
     
    Core Freedom likes this.
  7. Core Freedom

    Core Freedom Well-Known Member

    Thank you, James! I will try it although I'm not quite sure what to enter and I need to make sure the posts are not getting error messages that have polls. Right now when I enable the mod 'as is' it will give error messages and not even display the page. Let's see what Borbole says, then I'll get bold and try to insert your mod. You rock!!
     
  8. James

    James Well-Known Member

    It won't affect polls whatsoever. All it will change is the actual content of the message.
     
  9. Core Freedom

    Core Freedom Well-Known Member

    Well, then something is messing with the polls. For example, I just re-activated the mod and set forum #23 as the test forum. The mod works for some of the posts but not others. Here are some that I get error messages for as a non-member, simply browsing as a guest.

    this one does NOT have a poll but page still give "internal server error"

    http://www.corefreedom.com/threads/how-to-love-how-to-forgive-hitler-and-animal-cruelty.691/

    This one DOES have a poll and it also gives an "internal server error"

    http://www.corefreedom.com/threads/is-love-a-feeling-a-choice-fate-or-something-else.682/

    Also, is there a way to show only the first x-number of words of the FIRST post but not the answers also? As it is it shows x-number of posts on all subsequent answers also.
     
  10. James

    James Well-Known Member

    Do you want subsequent answers to not show at all? This may get to a point where it's more feasible to do as an add-on rather than a modification.
     
    Core Freedom likes this.
  11. Core Freedom

    Core Freedom Well-Known Member

    For the free forum it's fine if the answers or parts thereof, show. But for the paid forum I just want x-number of words showing so Google can pick up on the forums. But people should know that they need to be a paid member to see the full post. If I can achieve these 2 things then I'm happy.

    But I still have the issue that some of the posts redirect to an internal server error page when the mod is active. As soon as I deactivate it, I can view it again as a guest.
     
  12. James

    James Well-Known Member

    With template modifications you're going to have lots of nested template conditionals whereas it may be easier to do it as a modification.

    Let's see if borbole can edit his modification for you, and if not I'll look into this.
     
    borbole and Core Freedom like this.
  13. Core Freedom

    Core Freedom Well-Known Member

    Thank you, James!
     
  14. borbole

    borbole Well-Known Member

    Atm I do not have much free time to look into expanding my mod. So I think it would be better to give James 's suggestion a try first.
     
    Core Freedom likes this.

Share This Page