Announcement

Collapse
No announcement yet.

Can't add long piece of code to template.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Can't add long piece of code to template.

    Hi,

    I was trying to add a long piece of code (some openads codes) to forumdisplay template using the Style Manager.

    Upon clicking on "Save & Reload" button, the Template text area returned me with a blank box without any code in it. My forum section was also unaccessible until i reverted back to the code before.

    After shortening my code to about half its size, I managed to add it to the forumdisplay template without error.

    Therefore, I'm wondering if there is a limitation to the size/length of code we can add to the forumdisplay template?

    Can you suggest a workaround if there is a limitation of code we can add? e.g. placing my long piece of code into a file and then call this particular file from within forumdisplay template? How can I do it if it's possible?

    I'm using 3.6.8.

    Please advise.

  • #2
    Shouldnt be but posting the original code you were trying to add might help

    Comment


    • #3
      Hmmm, if it is a text limit, you could always make your own template hook and then add the stuff into a new template and eval it in a plugin.

      Example:

      Add this to the template (mine was added to the SHOWGROUPS template):
      Code:
      $template_hook[showgroups_moderators]
      Make a new template (mine is called "added_showgroups_moderators"):
      Code:
      your template html here
      Add this to a plugin for the page being called (like mine is for showgroups_start cuz it is on the showgroups.php page):
      Code:
      eval('$template_hook[showgroups_moderators] .= " ' . fetch_template('added_showgroups_moderators') . '";');

      Please don't PM or VM me for support - I only help out in the threads.
      vBulletin Manual & vBulletin 4.0 Code Documentation (API)
      Want help modifying your vbulletin forum? Head on over to vbulletin.org
      If I post CSS and you don't know where it goes, throw it into the additional.css template.

      W3Schools <- awesome site for html/css help

      Comment


      • #4
        My code is something like this, with many similar <if> conditions just like the part in bold.

        Has this got to do with the size of data we can store into the database?





        <if condition="in_array($forumid, array(5,31,6,7,27,9,20,66,26,35,14,24,32,17,75,11,12,73,34,33,40,28))">

        <if condition="$forumid == 5">
        <table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
        <tbody>
        <tr><td class="thead">Featured Advertisements - $foruminfo[title]</td></tr>
        </tbody>
        <tbody>
        <tr>
        <td class="alt2" width="100%" align="center">
        <table width="97%">
        <tr>
        <td>
        <center>
        <script language='JavaScript' type='text/javascript' src='http://www.xxxxxxxxxx.com/adserver/adx.js'></script>
        <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://www.xxxxxxxxxx.com/adserver/adjs.php?n=" + phpAds_random);
        document.write ("&amp;what=zone:41");
        document.write ("&amp;exclude=" + document.phpAds_used);
        if (document.referrer)
        document.write ("&amp;referer=" + escape(document.referrer));
        document.write ("'><" + "/script>");
        //-->
        </script><noscript><a href='http://www.xxxxxxxxxx.com/adserver/adclick.php?n=ad75692c' target='_blank'><img src='http://www.xxxxxxxxxx.com/adserver/adview.php?what=zone:41&amp;n=ad75692c' border='0' alt=''></a></noscript>
        </center>
        <br />
        <center><a href="http://www.xxxxxxxxxx.com/misc.php?do=page&template=Advertise">Advertise your banner here</a></center>
        </td>
        <td>
        <center>
        <script language='JavaScript' type='text/javascript' src='http://www.xxxxxxxxxx.com/adserver/adx.js'></script>
        <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://www.xxxxxxxxxx.com/adserver/adjs.php?n=" + phpAds_random);
        document.write ("&amp;what=zone:42");
        document.write ("&amp;exclude=" + document.phpAds_used);
        if (document.referrer)
        document.write ("&amp;referer=" + escape(document.referrer));
        document.write ("'><" + "/script>");
        //-->
        </script><noscript><a href='http://www.xxxxxxxxxx.com/adserver/adclick.php?n=a366b592' target='_blank'><img src='http://www.xxxxxxxxxx.com/adserver/adview.php?what=zone:42&amp;n=a366b592' border='0' alt=''></a></noscript>
        </center>
        <br />
        <center><a href="http://www.xxxxxxxxxx.com/misc.php?do=page&template=Advertise">Advertise your banner here</a></center>
        </td>
        </tr>

        </table>
        </td>
        </tr>
        </tbody>
        </table>
        <br /><br />
        </if>

        <if condition="$forumid == 31">
        ..
        </if>

        .
        .

        <if condition="$forumid == 28">
        ..
        </if>

        </if>

        Comment


        • #5
          Originally posted by U2Lynne View Post
          Hmmm, if it is a text limit, you could always make your own template hook and then add the stuff into a new template and eval it in a plugin.

          Example:

          Add this to the template (mine was added to the SHOWGROUPS template):
          Code:
          $template_hook[showgroups_moderators]
          Make a new template (mine is called "added_showgroups_moderators"):
          Code:
          your template html here
          Add this to a plugin for the page being called (like mine is for showgroups_start cuz it is on the showgroups.php page):
          Code:
          eval('$template_hook[showgroups_moderators] .= " ' . fetch_template('added_showgroups_moderators') . '";');
          Thanks I'll try that.

          Comment


          • #6
            I've made my own plugin but after dumping in the long code, I got the same error. Shorter code is fine.

            I guess I will have to call an external file rather?

            Comment


            • #7
              If the shorter code works, then perhaps you need to consider that the code you are NOT adding is the problem. What part are you taking out to get it to work?

              Please don't PM or VM me for support - I only help out in the threads.
              vBulletin Manual & vBulletin 4.0 Code Documentation (API)
              Want help modifying your vbulletin forum? Head on over to vbulletin.org
              If I post CSS and you don't know where it goes, throw it into the additional.css template.

              W3Schools &lt;- awesome site for html/css help

              Comment


              • #8
                Ok, i've solved the problem by splitting the codes into two templates and then have 1 template_hook for each.

                Thanks everyone.

                Comment

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