Specific Banner Per Forum

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • JustAskJulie
    Senior Member
    • Nov 2002
    • 368
    • 3.6.x

    Specific Banner Per Forum

    I want to put a specific sponsor banner in each forum. On vb2 I ended up creating a new template set for each banner I wanted displayed and then assigning that style to the particular forum. Is there another way I can do this that would force the banner regardless of what style is being used?
    Julie
  • Jake Bunce
    Senior Member
    • Dec 2000
    • 46598
    • 3.6.x

    #2
    Two options come to mind:

    1) Do the same thing you did with vB2, except create the extra styles as children of your main style. Then all you would have to do is add your banners to the header templates of the child styles. All other templates and style settings would be inherited from the parent style making for easy style management (unlike vB2).

    2) (without creating multiple styles) The $forumid variable parses on all forumdisplay, showthread, newreply, and newthread pages within a forum, so it can be used in the templates as an index into an array that contains your banners.

    In your phpinclude_start template, use this code:

    Code:
    $banner[[color=red]1[/color]] = "<a href=\"[color=red]LINK[/color]\" target=\"_blank\"><img src=\"[color=red]sponsor1.gif[/color]\" alt=\"\" border=\"0\" /></a>";
    Change the red code appropriately, where the number inside brackets is the forumid of the forum to which this banner code belongs. If you have more forums simply add more instances of the above code.

    Then insert this code into your header template:

    Code:
    $banner[$forumid]
    Now the banners will show up in their respective forums.

    Comment

    • JustAskJulie
      Senior Member
      • Nov 2002
      • 368
      • 3.6.x

      #3
      Is there a way to do this tho so that the banners are viewed regardless of what style is selected?

      Right now I have 3 user selectable styles and I would want the banner(s) to show up regardless of which of those styles is selected.

      With the above (as with the way I had it set up with vb2) if a user selected a different style than the one I had included the banner in then they didn't see the banners.
      Julie

      Comment

      • Jake Bunce
        Senior Member
        • Dec 2000
        • 46598
        • 3.6.x

        #4
        Using method 2 you could have a style tree like this:

        Parent - contains the phpinclude_start code
        --Style 1 - contains $banner[$forumid] in header
        --Style 2 - contains $banner[$forumid] in header
        --Style 3 - contains $banner[$forumid] in header

        The child styles in the above example should not have customized phpinclude_start templates. They should inherit the phpinclude_start template from the Parent so they all have access to the banner code.

        Comment

        • JustAskJulie
          Senior Member
          • Nov 2002
          • 368
          • 3.6.x

          #5
          Ok, I'll give that a try. Thanks Jake.
          Julie

          Comment

          • mfarmerhi
            Member
            • Mar 2003
            • 60

            #6
            Jake, I'm struggling with the same thing and would like to implement solution #2 you've suggested, but phpadnew's javascript invocation script includes more than just the image link you've used as an illustration.

            E.g. for one of my banners phpadnew's invocation is:
            Code:
            <script language='JavaScript' type='text/javascript'>
            <!--
               if (!document.phpAds_used) document.phpAds_used = ',';
               phpAds_random = new String (Math.random()); phpAds_random = phpAds_random.substring(2,11);
               
               document.write ("<" + "script language='JavaScript' type='text/javascript' src='");
               document.write ("http://mysite/~totalli/ads/adjs.php?n=" + phpAds_random);
               document.write ("&amp;what=zone:3");
               document.write ("&amp;exclude=" + document.phpAds_used);
               if (document.referer)
                  document.write ("&amp;referer=" + escape(document.referer));
               document.write ("'><" + "/script>");
            //-->
            </script><noscript><a href='http://mysite/~totalli/ads/adclick.php?n=a9b483f1' target='_blank'>
            <img src='http://mysite/~totalli/ads/adview.php?what=zone:3&amp;n=a9b483f1' border='0' alt=''></a></noscript>
            So... should ALL of that be included between the quotes you've used in your illustration above:
            Code:
            $banner[1] = "<script language='JavaScript' type='text/javascript'>
            <!--
               if (!document.phpAds_used) document.phpAds_used = ',';
               phpAds_random = new String (Math.random()); phpAds_random = phpAds_random.substring(2,11);
               
               document.write (\"<\" + \"script language='JavaScript' type='text/javascript' src='\");
               document.write (\"http://mysite/~totalli/ads/adjs.php?n=\" + phpAds_random);
               document.write (\"&amp;what=zone:3\");
               document.write (\"&amp;exclude=\" + document.phpAds_used);
               if (document.referer)
                  document.write (\"&amp;referer=\" + escape(document.referer));
               document.write (\"'><\" + \"/script>\");
            //-->
            </script><noscript><a href='http://mysite/~totalli/ads/adclick.php?n=a9b483f1' target='_blank'>
            <img src='http://mysite/~totalli/ads/adview.php?what=zone:3&amp;n=a9b483f1' border='0' alt=\''></a></noscript>";
            ???
            Last edited by mfarmerhi; Wed 25 Aug '04, 10:37pm.

            Comment

            • Jake Bunce
              Senior Member
              • Dec 2000
              • 46598
              • 3.6.x

              #7
              Originally posted by mfarmerhi
              So... should ALL of that be included between the quotes you've used in your illustration above...
              Yes, but you would need backslashes on every quotation mark in the code.

              You can avoid the trouble of assigning that code to a variable by using a template conditional in the header instead. For example:

              Code:
              [color=red]<if condition="$forumid == X">[/color]
              <script language='JavaScript' type='text/javascript'>
              <!--
                 if (!document.phpAds_used) document.phpAds_used = ',';
                 phpAds_random = new String (Math.random()); phpAds_random = phpAds_random.substring(2,11);
                 
                 document.write ("<" + "script language='JavaScript' type='text/javascript' src='");
                 document.write ("http://mysite/~totalli/ads/adjs.php?n=" + phpAds_random);
                 document.write ("&amp;what=zone:3");
                 document.write ("&amp;exclude=" + document.phpAds_used);
                 if (document.referer)
                    document.write ("&amp;referer=" + escape(document.referer));
                 document.write ("'><" + "/script>");
              //-->
              </script><noscript><a href='http://mysite/~totalli/ads/adclick.php?n=a9b483f1' target='_blank'>
              <img src='http://mysite/~totalli/ads/adview.php?what=zone:3&amp;n=a9b483f1' border='0' alt=''></a></noscript>
              [color=red]</if>[/color]
              Where X is the forumid of the forum to which this banner code belongs. In this example, you would use this code in the header and not use the phpinclude_start template at all.

              Comment

              • mfarmerhi
                Member
                • Mar 2003
                • 60

                #8
                Thanks, Jake! (And incredible how fast you got back to me!)

                Yea, I realized the backslashes were needed after posting and went back to edit my example to read correctly.

                Again, thanks!

                (runs off to implement it)

                Comment

                • mfarmerhi
                  Member
                  • Mar 2003
                  • 60

                  #9
                  Jake,

                  Much thanks! Works like a charm.

                  Now I'm just stuck looking for the right variable to use in the showthread page, to also show the forum specific banner in all the theads in that forum.

                  Apparently the threads don't use $forumid?

                  Comment

                  • Jake Bunce
                    Senior Member
                    • Dec 2000
                    • 46598
                    • 3.6.x

                    #10
                    $forumid should work in the header template for all pages within a forum, including SHOWTHREAD pages.

                    If you are using this variable in a template other than the header template then you might have scope problems. Try using $GLOBALS[forumid] instead, or possibly $foruminfo[forumid].

                    Comment

                    • mfarmerhi
                      Member
                      • Mar 2003
                      • 60

                      #11
                      I'm using the first method discussed, that is, defining the banners (e.g. $banner[18] = ""; ) in the phpinclude, then calling them in the forum display: $banner[$forumid]

                      In editing the displaythread template (that template and not the header include for that template), I attempted adding the same: $banner[$forumid]

                      No errors, but no banner displays either.

                      Sorry, php newb here, but I tried your suggestions. Both
                      Code:
                      $banner[$GLOBALS[forumid]]
                      or
                      Code:
                      $banner[$foruminfo[forumid]]
                      give me errors.

                      Comment

                      • Jake Bunce
                        Senior Member
                        • Dec 2000
                        • 46598
                        • 3.6.x

                        #12
                        oh, put curlies around those:

                        Code:
                        {$banner[$GLOBALS[forumid]]}
                        I tested the old way in the SHOWTHREAD template ($banner[$forumid]) and it works for me. If you can't get any of these 3 methods to work then I will need to take a look. Send me a private message with a URL and admin login for your forums and I will take a look.

                        Comment

                        • mfarmerhi
                          Member
                          • Mar 2003
                          • 60

                          #13
                          Yea... it's just not working. I'll PM you tomorrow, but it appears that it's just not accessing the variable $forumid from the showthread template (BTW, I'm still using Vb2.3)

                          No matter how I called it
                          Code:
                          {$banner[$GLOBALS[forumid]]}
                          
                          {$banner[$foruminfo[forumid]]}
                          
                          or
                          
                          $banner[$forumid]
                          ...the value was -0-
                          Last edited by mfarmerhi; Tue 7 Sep '04, 12:56am.

                          Comment

                          • Jake Bunce
                            Senior Member
                            • Dec 2000
                            • 46598
                            • 3.6.x

                            #14
                            Originally posted by mfarmerhi
                            (BTW, I'm still using Vb2.3)
                            That's why it's not working. This is for vB3.

                            I will look at making this work for vB2 when I get home this evening.

                            Comment

                            • Jake Bunce
                              Senior Member
                              • Dec 2000
                              • 46598
                              • 3.6.x

                              #15
                              This works in the showthread template in vB2:

                              Code:
                              {$banner[$forum[forumid]]}
                              The phpinclude code is the same.

                              Comment

                              widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
                              Working...