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

XF 1.4 String manipulation in templates

Discussion in 'XenForo Questions and Support' started by Kevin Remer, Feb 11, 2015.

  1. Kevin Remer

    Kevin Remer New Member

    Is there a way to do string manipulation (indexOf, subStr, etc.) when using <xen:set>?

    For example:
    Then check $test_content to see if there is an IMG tag present, and if so, get the index of that tag.
    Then do the same for the /IMG tag.
    Then do a substr using the location of those two tags to get the value that is between the tags.
    Last edited: Feb 11, 2015
  2. Kevin Remer

    Kevin Remer New Member

    I figured out how to do what I wanted. This is for using Twitter Cards using the text and image from the first post of a given thread.

    I made two files in the /library/TwitterCard folder.

    index.php - This checks for an image in the first post of a thread to see if there is an image (assumes only 1 image). It also adds an og;image tag for the image if it finds one (useful for facebook sharing).
    descr.php - This one strips the IMG tag out of the description, if one exists
    I then modified the $head.description portion of the thread_view template
    End result, anything an admin/moderator posts will have the included meta tags for a valid Twitter Card.[/quote]

Share This Page