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

Template edits needed to insert banner ad code

Discussion in 'Custom Service/Development Requests' started by VtoX, Sep 11, 2012.

  1. VtoX

    VtoX Member

    Hi guys.

    I need someone to edit a few templates to add some banner ad code to display for guests only.

    I can pay through Paypal.

  2. Chris D

    Chris D XenForo Developer Staff Member

    Hi VtoX,

    How about we do it another way...

    I could easily instruct you in this thread how to do it. You then save a little bit of money and also, you might learn something for the future.

    It's very easy so I wouldn't want to take money from you and I think it's a good thing to learn...
  3. VtoX

    VtoX Member

    Hi Chris.

    Thank you. That is very kind of you to offer. If you feel it is easy enough and won't take up too much of your time I'd certainly appreciate the help.
  4. Chris D

    Chris D XenForo Developer Staff Member


    First of all, there's already a load of blank templates that you can insert banner ad code to.

    This awesome post by Slavik shows the location of most of the ad templates:


    This shows you the location of the ad_templates and their names. Once you have worked out which locations you want to display ads, the following example is if you want to insert banner ad code into the ad_above_content template:
    1. Go to Admin CP
    2. Go to Appearance Tab
    3. Click Templates
    4. In the filter box type ad_above_content
    5. Click the template
    6. Paste in your ad code.
    That will display the ads to all users. If you wanted to display it to guests only, it would look like this:
    <xen:if is="!{$visitor.user_id}">
    <Pasted ad code>​
    actionmedia, magdi5 and VtoX like this.
  5. VtoX

    VtoX Member

    Wow. Thanks Chris. Looks like I will be able to handle it.

    Thanks so much for taking the time to help me.
    Chris D likes this.
  6. Chris D

    Chris D XenForo Developer Staff Member

    Even if you get stuck, stick with it and feel free to post again if you have any more questions.
    Dodgeboard and BenForum like this.
  7. BenForum

    BenForum Active Member

    great chris you are doing a very good job here
    Chris D likes this.
  8. VtoX

    VtoX Member

    Hey Chris.

    I hate to bother you but I'd like to start adding the ad code to the templates like you instructed but I have a little road block.

    I'd like to duplicate my current style and make changes to the duplicate style for testing, etc to make sure I have everything working before I go live with it. Then I figured I would rename the new style with the new ad code and go live with it once it's working fine and disable the existing style.

    Is there an easy way to do this?

    Thanks again for all your help.
  9. Chris D

    Chris D XenForo Developer Staff Member

    If you go to:

    Admin CP > Appearance > Styles > Create New Style

    What you want to do is give it a name then under "Parent Style" select your existing style.

    The new style will be identical to the original style. Make all the changes you need to make in the new style. If you make any mistakes in the new style, you can revert the changes for that template back to the original style. Then, when you're happy, you can delete the original style.
    VtoX likes this.
  10. VtoX

    VtoX Member

    Thank you very much again Chris. I really appreciate it.
    Chris D likes this.
  11. wickedstangs

    wickedstangs Well-Known Member

    How do you show to all?
  12. Chris D

    Chris D XenForo Developer Staff Member

    Just paste the ad code into a template.

    You don't need <xen:if tags if you want things to show to all.
  13. VtoX

    VtoX Member

    Slowly getting there Chris but I have another question. I hate to ask but hopefully your assistance will be of help to others too.

    I'm using an ad management network that loads all the ads asynchronously.

    They provide little snippits of code to place where I want the ads to appear. My problem is that I do not know how to align the ads. I need to be able to left justify, center or right justify the ad.

    The ad code looks like this:

    <div id="bxk33402"></div>
    I understand I place it into the template that I want it to appear but do you know I can modify the position and padding if necessary?

    The ad management network also provides a script that must be placed inside the head tag. Where would that be.

    Sorry to ask what must be such simple questions to you.

  14. actionmedia

    actionmedia Member

    I added the code however when someone views my site on a mobile device (iphone) the banner is too wide, and makes the forum look too narrow. If you go to www.cigarpass.com/forum you'll see what I mean. Any way to have the banner (image) resize correctly? It used to work on my old forum, so may be just a code insert I need? Thanks...
  15. Brogan

    Brogan XenForo Moderator Staff Member

  16. actionmedia

    actionmedia Member

    My banner ad rotator is a custom php script (very small). It uses an iframe - is that a problem?
    <!-- ::: BANNER ADS ::: -->
    <xen:if is="@enableResponsive">
    <iframe src="http://www.domain.com/ad.php" width="475" height="65" frameBorder="no" scrolling="no" marginheight="5" hspace="5" vspace="5">
      <p>Your browser does not support iframes.</p>
    <!-- ::: BANNER ADS ::: -->

Share This Page