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

Using Code in Posts doesn't work

Discussion in 'XenForo Questions and Support' started by Core Freedom, Aug 28, 2012.

  1. Core Freedom

    Core Freedom Well-Known Member

    Hi all,

    I'm trying to add an aWeber html code to a post by clicking the brackets. I tried saying "General Code" and "HTML" but neither shows up right. Here is what I enter:

    <script type="text/javascript" src="http://forms.aweber.com/form/24/517111224.js"></script>

    Am I missing something?

    Alternatively, if this is not working within posts, is it possible to put the code in the sidebar? If so, how?

    Thank you!
  2. Chris D

    Chris D XenForo Developer Staff Member

    The code button in the editor is for sites like this where it's necessary to share and display code.

    For example:

    public function isUserSuperAdmin(array $user)
    $superAdmins preg_split(
    return (
    $user['is_admin'] && in_array($user['user_id'], $superAdmins));
    The code isn't supposed to execute, it's just there to display code.

    What is the code supposed to do, and why would you want it in every post?

    As ever, you would need to insert HTML code directly into a template.
    Core Freedom likes this.
  3. Core Freedom

    Core Freedom Well-Known Member

    Hi Chris, thanks for responding. It's a newsletter sign up to aWeber. So I wanted the form to show up under the post announcement, just in that particular post, not in every post. Hhhm. If that won't work, is there a way to get the form installed on the side bar?
  4. Andy.N

    Andy.N Well-Known Member

    Install Widget Framework addon and create a HTML sidebar where you can paste the code in.
    Or you can create a BB Media code to embed your form. It's the same thing as youtube
    Core Freedom likes this.
  5. borbole

    borbole Well-Known Member

    Attached Files:

    Core Freedom and Chris D like this.
  6. Chris D

    Chris D XenForo Developer Staff Member

    You can still do this.

    First of all, you need the post ID of the post that you want the form to appear in. You can get that by hovering over the permalink in the bottom right corner of the post. So, the post I've quoted is 404553.

    You would then need to go to your "message" template.

    Find: {xen:raw $messageContentAfterTemplate}

    And below add:

    <xen:if is="{$message.post_id} == XX">
    <script type="text/javascript" src="http://forms.aweber.com/form/24/517111224.js"></script>

    (where XX is your post ID)

    That should work.

    This solution isn't ideal, and it's not something you'd be wanting to do regularly, but it will work.

    Also, you would need to remember this in case of future XenForo updates. If XenForo updates that template, then you would need to remove the above code, revert the template and add the change back in.

    EDIT: And after all that, Andy's solution is much more elegant:

    Core Freedom likes this.
  7. Core Freedom

    Core Freedom Well-Known Member

    Thank you all! And yes, Borbole, I'll need that. Will contact you directly.
    borbole likes this.

Share This Page