XF 1.4 Finding head section and body tag in front end

Dan Allen

Active member
We are looking at putting stripes around the outside edge of our XF installation. We have php files that need to be included, one in the head section of every page and another immediatly after the body tag, before anything else. I have taken a look at the file system, and the Resources tab above and unfortunately, I am not finding the information I am looking for too quickly. In fact I am concerned that this surgery on the code might be wildly difficult.

Can you offer any tips on where to put a php include in the header and another on the body tag of every front end page?

How about the admin pages? A working prototype of the stripes is available here. Deeper explanation of the stripes is here.

upload_2015-1-14_23-28-31.webp

Thank you.
 
You can't run php in a template like that.

It may help if you explain what you are trying to do, but it sounds like the development forum may be the best place for it.
 
The simplest way would be via the xen:callback tag.

Create your php file, then call it in the template using:
Code:
<xen:callback class="example" method="test"></xen:callback>
 
so if my file is called additionalphp.php...

Is there a certain diretory where it needs to be stored?

What does the callback tag looking like? Here is my guess, and I guess it won't work.:
<xen:callback class="additionalphp.php" method="test"></xen:callback>

also, how did you get the trick code block surrounding your code?

upload_2015-1-29_15-19-14.webp
 
Thank you, got it to work, using the example you provided. The objective was to put randomly colored stripes around the page. Here are three successive page loads:
upload_2015-1-30_0-28-1.webp upload_2015-1-30_0-28-50.webp upload_2015-1-30_0-29-27.webp

Here is the callback in the template:
upload_2015-1-30_0-33-0.webp

Here is the code:
Code:
<?php

class Example_Test
{
  public static function getHtml()
  {
     $colorband[0]['redlow']    = 255;
     $colorband[0]['redhigh']    = 255;
     $colorband[0]['greenlow']    = 150;
     $colorband[0]['greenhigh'] = 215;
     $colorband[0]['bluelow']    = 0;
     $colorband[0]['bluehigh']    = 60;
     $colorband[0]['targetWidth']   = 15;
     $colorband[0]['maxWidth']   = 3;
     $colorband[0]['minWidth']   = 1;

     $colorband[1]['redlow']    = 0;
     $colorband[1]['redhigh']    = 255;
     $colorband[1]['greenlow']    = 0;
     $colorband[1]['greenhigh'] = 0;
     $colorband[1]['bluelow']    = 0;
     $colorband[1]['bluehigh']   = 255;
     $colorband[1]['targetWidth']   = 25;
     $colorband[1]['maxWidth']   = 7;
     $colorband[1]['minWidth']   = 1;
     shuffle($colorband);
     $borderWidthTargetArray[0]=3;
     $borderWidthTargetArray[1]=3;
     $borderStyle='';
     $numStripeArray=0;
     $numStripeArrays = count($colorband);
     $ij=0;
     $betterArray=array();
     foreach( $colorband  as $key=>$stripes):
         $borderWidthTarget = $stripes['targetWidth'];
         $numStripeArray++;
         $borderWidthtotal=0;
         $borderWidthtotal8=0;
         $maxWidth=$stripes['maxWidth'];
         $minWidth=$stripes['minWidth'];
         while ($borderWidthtotal < $borderWidthTarget and $ij < 500):
           $borderWidthThisLayer=rand($minWidth, $maxWidth);
          $borderWidthtotal=$borderWidthtotal+$borderWidthThisLayer;
           $betterArray[]= $borderWidthThisLayer;
           $thisStripe =  $borderWidthThisLayer . "px solid " . "rgb("
           . rand($stripes['redlow'], $stripes['redhigh'])    . ","
           . rand($stripes['greenlow'], $stripes['greenhigh'])  . ","
           . rand($stripes['bluelow'], $stripes['bluehigh'])    . "
           );";
          $borderStyle .=  '#customwrap' . $ij
          . " {border-left:" .$thisStripe . "border-top:" .$thisStripe  . "border-bottom:" .$thisStripe . "border-right:" .$thisStripe ."z-index:999999;}
                       ";
           $ij++;
           if ($borderWidthTarget-$borderWidthtotal<=$maxWidth):
             $borderWidthThisLayer=$borderWidthTarget-$borderWidthtotal-1;
             $borderWidthtotal=$borderWidthtotal+$borderWidthThisLayer;
             $betterArray[]= $borderWidthThisLayer;
             $thisStripe =  $borderWidthThisLayer . "px solid " . "rgb("
             . rand($stripes['redlow'], $stripes['redhigh'])    . ","
             . rand($stripes['greenlow'], $stripes['greenhigh'])  . ","
             . rand($stripes['bluelow'], $stripes['bluehigh'])    . "
             );";
             $borderStyle .=  '#customwrap' . $ij
          . " {border-left:" .$thisStripe . "border-top:" .$thisStripe  . "border-bottom:" .$thisStripe . "border-right:" .$thisStripe ."z-index:999999;}
                       ";

             $ij++;
             $borderWidthThisLayer=1;
             $borderWidthtotal=$borderWidthtotal+$borderWidthThisLayer;
             $betterArray[]= $borderWidthThisLayer;
             $borderStyle .=  '#customwrap' . $ij
          . " {border-left:3px solid #000; border-bottom:3px solid #000;  border-top:3px solid#000;  border-right:3px solid#000;  #000;z-index:999999;}";


             if ($numStripeArray == $numStripeArrays):
               $borderStyle .=  '#customwrap' . $ij
               . " {box-shadow:inset 0 0 1px  #000;}";
             else:
               $ij++;
             endif;
           endif;

         endwhile;
     endforeach;


     echo '<style>' . $borderStyle  . '</style>';
     if (isset($betterArray)):
       foreach($betterArray as $key=>$better):

       echo '<div id="customwrap' . $key . '">';

       endforeach;
     endif;


  }
}

Link to working example
 
Back
Top Bottom