phpads

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • flstreetscene
    Member
    • Nov 2003
    • 85

    phpads

    When I try to insert this code into my navbar between the < /br> tags (where I previously had html style banner advertisement)

    Code:
    <?php 
    if (@include(getenv('DOCUMENT_ROOT').'/phpadsnew/phpadsnew.inc.php')) { 
    if (!isset($phpAds_context)){ $phpAds_context = array(); } 
    $phpAds_raw = view_raw('', 2, '_blank', '', '0', $phpAds_context); 
    echo $phpAds_raw['html']; 
    } 
    ?>
    I get this error;

    Code:
    The following error occurred when attempting to evaluate this template: 
    
    Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/zeno/domains/floridastreetscene.com/public_html/forums/includes/adminfunctions_template.php(3055) : eval()'d code on line 144 
    
    This is likely caused by a malformed conditional statement. It is highly recommended that you fix this error before continuing, but you may continue as-is if you wish.
  • MrNase
    Senior Member
    • Jun 2003
    • 3575
    • 3.8.x

    #2
    vB3 doesn't allow this kind of PHP code in the templates

    You should search the documentation (http://www.vbulletin.com/docs/html) for the term 'The PHP Include Templates'


    Here's how it could work:

    Place
    Code:
       if (@include(getenv('DOCUMENT_ROOT').'/phpadsnew/phpadsnew.inc.php')) { 
      if (!isset($phpAds_context)){ $phpAds_context = array(); } 
      $phpAds_raw = view_raw('', 2, '_blank', '', '0', $phpAds_context);
    to the phpinclude_start template. From now on you can use the variable

    $phpAds_raw[html]

    whereever you need it
    That's the end of that!

    Comment

    • flstreetscene
      Member
      • Nov 2003
      • 85

      #3
      I did just that and it's still not working. (nothing is showing up there to be exact)

      This is what my phpinclude_start template looks like now;
      Code:
      // Example of how to include a seperate file:
      // ob_start();
      // require("yourheader.html");
      // $header = ob_get_contents();
      // ob_end_clean();
         if (@include(getenv('DOCUMENT_ROOT').'/phpadsnew/phpadsnew.inc.php')) { 
        if (!isset($phpAds_context)){ $phpAds_context = array(); } 
        $phpAds_raw = view_raw('', 2, '_blank', '', '0', $phpAds_context);
      (I've made no changes to the phpinclude_end template)

      and I've placed
      Code:
      $phpAds_raw[html]
      between the <br /> tags.

      Comment

      • MrNase
        Senior Member
        • Jun 2003
        • 3575
        • 3.8.x

        #4
        Well, Iam not that familiar with phpAds.. Are you sure that code works without vB?

        The following errors are possible:

        The file specified at the very beginning of your custom code doesn't exist.
        The variable is empty for some reason (no data to display).

        You may try the following:

        Code:
          // Example of how to include a seperate file:
         // ob_start();
         // require("yourheader.html");
         // $header = ob_get_contents();
         // ob_end_clean();
        include (getenv('DOCUMENT_ROOT').'/phpadsnew/phpadsnew.inc.php');
          $phpAds_raw = view_raw('', 2, '_blank', '', '0', $phpAds_context);
        With this code you should at least see an error message if the file phpadsnew.inc.php doesn't exist at that location
        That's the end of that!

        Comment

        • hpwilhelm
          Member
          • Dec 2003
          • 41
          • 3.6.x

          #5
          Here is what I did for a client:
          Code:
          // toppbanner
            ob_start();
            if (@include(getenv('DOCUMENT_ROOT').'/banner/phpadsnew.inc.php')) {
            		if (!isset($phpAds_context)) $phpAds_context = array();
            		$phpAds_raw = view_raw ('zone:1', 0, '', '', '1', $phpAds_context);
            		$phpAds_context[] = array('!=' => 'bannerid:'.$phpAds_raw['bannerid']);
            		$phpAds_context[] = array('!=' => 'campaignid:'.$phpAds_raw['campaignid']);
            		echo $phpAds_raw['html'];
            	}
            $toppbanner = ob_get_contents();
            ob_end_clean();
          Then I placed $toppbanner in the header template.

          I could not get phpadsnew's generate code for template invocation function to work, so just use the regular php invocation code and set the variable in php_include.

          Comment

          • flstreetscene
            Member
            • Nov 2003
            • 85

            #6
            Originally posted by hpwilhelm
            Here is what I did for a client:
            Code:
            // toppbanner
            ob_start();
            if (@include(getenv('DOCUMENT_ROOT').'/banner/phpadsnew.inc.php')) {
            		if (!isset($phpAds_context)) $phpAds_context = array();
            		$phpAds_raw = view_raw ('zone:1', 0, '', '', '1', $phpAds_context);
            		$phpAds_context[] = array('!=' => 'bannerid:'.$phpAds_raw['bannerid']);
            		$phpAds_context[] = array('!=' => 'campaignid:'.$phpAds_raw['campaignid']);
            		echo $phpAds_raw['html'];
            	}
            $toppbanner = ob_get_contents();
            ob_end_clean();
            Then I placed $toppbanner in the header template.

            I could not get phpadsnew's generate code for template invocation function to work, so just use the regular php invocation code and set the variable in php_include.
            Where does that code go?

            Comment

            • Zachery
              Former vBulletin Support
              • Jul 2002
              • 59097

              #7
              Don't rely on DOCUMENT_ROOT try setting the real path to the file.

              Comment

              • hpwilhelm
                Member
                • Dec 2003
                • 41
                • 3.6.x

                #8
                Originally posted by Zachery
                Don't rely on DOCUMENT_ROOT try setting the real path to the file.
                As long as it works, I see no need to change it...

                (It is the auto-generated invocation code)

                Comment

                • hpwilhelm
                  Member
                  • Dec 2003
                  • 41
                  • 3.6.x

                  #9
                  Originally posted by flstreetscene
                  Where does that code go?
                  phpinclude_start template

                  But you need to generate your own invocationcode in phpadsnew.

                  Comment

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