Header and Footer

Tips and tricks to get more out of kPlaylist

Header and Footer

Postby Spoon » Thu Jun 01, 2006 1:11 pm

Hey All,

I'm new to Kplaylist, but not new to development. I've noticed that Kplaylist has everything thrown into one file for some reason and this makes it challenging to muddle throught the code and figure out where the header and footer could be placed. Basically, I need to put my .js nav menu and standard footer across the top and bottom respectivley and would like to know what part of the code will be the best spot to put this. I'd like to use a php include, but I can also use html.

Just so I make things clear, the nav menu has four .js files and one .css file that it relys on to function.

This is a nice piece of code without question, however, I've never seen or developed source code that has the size Kplaylist has without using external files such as .tpl, smarty, etc... to make things easier in the end. Therefore, any help would be great.
Spoon
 
Posts: 6
Joined: Thu Jun 01, 2006 1:00 pm

Re: Header and Footer

Postby aba » Thu Jun 01, 2006 2:28 pm

Spoon wrote:Hey All,

I'm new to Kplaylist, but not new to development. I've noticed that Kplaylist has everything thrown into one file for some reason and this makes it challenging to muddle throught the code and figure out where the header and footer could be placed. Basically, I need to put my .js nav menu and standard footer across the top and bottom respectivley and would like to know what part of the code will be the best spot to put this. I'd like to use a php include, but I can also use html.

Just so I make things clear, the nav menu has four .js files and one .css file that it relys on to function.

This is a nice piece of code without question, however, I've never seen or developed source code that has the size Kplaylist has without using external files such as .tpl, smarty, etc... to make things easier in the end. Therefore, any help would be great.


kPlaylist separated in it's source files, you can download from here: http://kplaylist.net/index.php?miscdownloads=true

kPlaylist design files: http://www.kplaylist.net/getdesign.php. Read this
'howto' to understand it's layout: http://www.kplaylist.net/forum/viewtopic.php?t=1109

Åge
aba
Site Admin
 
Posts: 2325
Joined: Wed May 08, 2002 9:19 am

Postby Spoon » Thu Jun 01, 2006 3:36 pm

aba - thanks a lot for the quick response. This is exactly what I needed!
Spoon
 
Posts: 6
Joined: Thu Jun 01, 2006 1:00 pm

Postby Spoon » Thu Jun 01, 2006 7:55 pm

aba,

I have another quick question. I managed to get my header and footer incorporated in Kplaylist, however, I cannot stream audio at all now.

When I click "play" all I get is a blank index.php page with only my header showing. However, when I remove the include php header file from index.php everything streams fine.

I was hoping you had a suggestion for a work around or trying something different.

Thanks
Spoon
 
Posts: 6
Joined: Thu Jun 01, 2006 1:00 pm

Postby aba » Thu Jun 01, 2006 9:17 pm

Spoon wrote:aba,

I have another quick question. I managed to get my header and footer incorporated in Kplaylist, however, I cannot stream audio at all now.

When I click "play" all I get is a blank index.php page with only my header showing. However, when I remove the include php header file from index.php everything streams fine.

I was hoping you had a suggestion for a work around or trying something different.

Thanks


You shoulden't incorporate the design inside the index.php file, because that will mess up all the calls that does not involve HTML. Instead, download top and bottom from http://www.kplaylist.net/getdesign.php and include your code there.

Åge
aba
Site Admin
 
Posts: 2325
Joined: Wed May 08, 2002 9:19 am

Postby Spoon » Thu Jun 01, 2006 9:30 pm

aba,

I tried doing thta before I wrote an include since what you are saying holds true about the calls. However, the top.kpp was the first test I had done and nothing worked. If I'm not mistaken, you want me to replace the code in the top.hpp file, correct? If not, what are you instructing me to do inthe file? I've been struggling with this for hours, but since your source code is excellent I want to try and make this work.

Here is what O originally put in the config.php file
Code: Select all
$cfg['designmap'] = array('login' => '', 'infobox' => '', 'endmp3table' => '', 'top' => 'top.kpp', 'bottom' => 'bottom.kpp', 'blackbox' => '');


Any other suggestions?
Spoon
 
Posts: 6
Joined: Thu Jun 01, 2006 1:00 pm

Postby aba » Thu Jun 01, 2006 9:47 pm

Spoon wrote:aba,

I tried doing thta before I wrote an include since what you are saying holds true about the calls. However, the top.kpp was the first test I had done and nothing worked. If I'm not mistaken, you want me to replace the code in the top.hpp file, correct? If not, what are you instructing me to do inthe file? I've been struggling with this for hours, but since your source code is excellent I want to try and make this work.

Here is what O originally put in the config.php file
Code: Select all
$cfg['designmap'] = array('login' => '', 'infobox' => '', 'endmp3table' => '', 'top' => 'top.kpp', 'bottom' => 'bottom.kpp', 'blackbox' => '');


Any other suggestions?


I assume you have top.kpp and bottom.kpp in the same directory as the script? What happens after you alter the .kpp file(s)? Does the design change in any way? If no visual changes are seen, probably the script can't open the kpp files. If kP(laylist) can't open the files listed in the 'designmap', kP will resort to the inbuilt design and thus ignore the kpp files. The cause of this can be: no permission to open the specified file(s) or that the files does not exist in the path specified.

Åge
aba
Site Admin
 
Posts: 2325
Joined: Wed May 08, 2002 9:19 am

Postby Spoon » Thu Jun 01, 2006 10:57 pm

Yes, I see no changes when I use my code inside the top and bottom .kpp files. It is also in the same dir as the config.php file. Am I suppose to simply open the top.kpp file I downloaded and overwrite the code that already exists with my own code? My code consists of .js inclusion, .css inclusion, and html.

I erased this entire code
Code: Select all
switch($this->style)
      {
         case 0:
            ?>
            <table width="100%" border="0" align="left" cellspacing="0" cellpadding="0">
            <tr>
               <td align="left" width="70%" valign="top">
               <?php if ($this->addform) $this->form(); ?>
               <table width="100%" border="0" cellpadding="0" cellspacing="0">               
               <tr>
               <td>
            <?php
         break;

         case 1:
            ?>
            <table width="100%" border="0" align="left" cellspacing="0" cellpadding="0">
            <tr>
               <td width="320" valign="top">
               <?php infobox(); ?></td>
               <td align="left" valign="top">
                  <?php if ($this->addform) $this->form(); ?>
                  <table width="100%" border="0" cellpadding="0" cellspacing="0">
                  <tr><td height="5"></td></tr>
                  <tr>
                  <td>                  
            <?php
         break;
      }
   

and put my own code in its place.

What does case 0 and case 1 pertain to?

Edit: I was thinking... perhaps it is possible to use top.php just in case the .kpp strips the .js code before parsing? I know that templates (.tpl) and smarty plates always strip certain source code before rendering.
Spoon
 
Posts: 6
Joined: Thu Jun 01, 2006 1:00 pm

Postby aba » Thu Jun 01, 2006 11:25 pm

Spoon wrote:What does case 0 and case 1 pertain to?

Edit: I was thinking... perhaps it is possible to use top.php just in case the .kpp strips the .js code before parsing? I know that templates (.tpl) and smarty plates always strip certain source code before rendering.


If you intend to replace the entire top file, make sure you avoid
it being parsed as PHP by escaping it by putting ?> in the top.

0/1 is from the 'style' in options (menu right = 0, menu left = 1).

But still, if you replaced the contents of that file with HTML, and kP still worked, It's highly likely that it's not reading your files. Why? Because you
would have a PHP parse error and the script would terminate and leave a blank page.
aba
Site Admin
 
Posts: 2325
Joined: Wed May 08, 2002 9:19 am

Postby Spoon » Thu Jun 01, 2006 11:43 pm

It looks like your last suggestion helped...I made a little more progress. Now, I get the top nav to work when dumping the code into top.kpp, however, there is one small problem...everything that the design.php file outputs such as the left menu etc... and middle playlist, is all pushed way down the page about to where a footer would normally be situated. So there is a large amount of spave between the two items.

Btw, I appreciate the help very much!
Spoon
 
Posts: 6
Joined: Thu Jun 01, 2006 1:00 pm

Postby aba » Thu Jun 01, 2006 11:52 pm

Spoon wrote:It looks like your last suggestion helped...I made a little more progress. Now, I get the top nav to work when dumping the code into top.kpp, however, there is one small problem...everything that the design.php file outputs such as the left menu etc... and middle playlist, is all pushed way down the page about to where a footer would normally be situated. So there is a large amount of spave between the two items.

Btw, I appreciate the help very much!


Now it's handy with a little HTML knowledge. Hopefully, you have this. You are a kind of a pilot regarding the customization on this level. I want to help out, but I am not very fond of debugging HTML.. :) But please, post back on your progress and in any way I can make it easier to customize in the future.
aba
Site Admin
 
Posts: 2325
Joined: Wed May 08, 2002 9:19 am

Postby lrdsatyr8 » Sun Jul 02, 2006 10:30 am

Well I was trying to do the same thing myself... to be able to come up with a header and footer for the pages and here's what I came up with.

If you've got the split apart php files open config.php, otherwise, at the top of the main php file, just after all the $cfg[] varibles have been set and look for this line:

Code: Select all
// end of configuration
if (file_exists('kpconfig.php')) include('kpconfig.php');


Before that add the following:

Code: Select all
// This will be displayed at the top of every page.  The Header Code
$cfg['topheader'] = '
            <tr height=40 bgcolor=blue>
        <td colspan=2 align=center>
        <font color=yellow><B>THIS IS THE TOP OF THE PAGE!</B></font>
        </td>
        </tr>
    ';
   
// This will be displayed at the bottom of every page.  The Footer Code
$cfg['bottomfooter'] = '
            <tr height=40 bgcolor=blue>
        <td colspan=2 align=center>
        <font color=yellow><b>THIS IS THE BOTTOM OF THE PAGE</b></font>
        </td>
        </tr>
    ';


Now mind you this HTML code can be changed to whatever you want, just preserve the colspan=2 in the TD commands

Now that you got that part done, save what you got and again, if you have the separate PHP files, open design.php or if not, look for the following code:

Code: Select all
$kdesign['top'] = '
    switch($this->style)
       {
       case 0:
       ?>
       <table width="100%" border="0" align="left" cellspacing="0" cellpadding="0">
        <tr>
          <td align="left" width="70%" valign="top">
          <?php if ($this->addform) $this->form(); ?>
          <table width="100%" border="0" cellpadding="0" cellspacing="0">
             <tr>
   <td>
   <?php
   break;

      case 1:
        ?>
         <table width="100%" border="0" align="left" cellspacing="0" cellpadding="0">
         <?php echo $TopHeader; ?>
            <tr>
   <td width="320" valign="top">
   <?php infobox(); ?></td>
   <td align="left" valign="top">
   <?php if ($this->addform) $this->form(); ?>
   <table width="100%" border="0" cellpadding="0" cellspacing="0">
   <tr><td height="5"></td></tr>
   <tr>
   <td>                  <?php
   break;
        }
';


and replace it with this code:

Code: Select all
$kdesign['top'] = '
      
    switch($this->style)
      {
         case 0:
            ?>
            <table width="100%" border="0" align="left" cellspacing="0" cellpadding="0">
        <?php echo $cfg["topheader"]; ?>
        <tr>
               <td align="left" width="70%" valign="top">
               <?php if ($this->addform) $this->form(); ?>
               <table width="100%" border="0" cellpadding="0" cellspacing="0">               
               <tr>
               <td>
            <?php
         break;

         case 1:
            ?>
            <table width="100%" border="0" align="left" cellspacing="0" cellpadding="0">
        <?php echo $cfg["topheader"]; ?>
            <tr>
               <td width="320" valign="top">
               <?php infobox(); ?></td>
               <td align="left" valign="top">
                  <?php if ($this->addform) $this->form(); ?>
                  <table width="100%" border="0" cellpadding="0" cellspacing="0">
                  <tr><td height="5"></td></tr>
                  <tr>
                  <td>                  
            <?php
         break;


Now if you look closely, the only thing that was added to this code was the <?php echo $cfg["topheader"]; ?> just after the first TABLE command in both case instances. So if you are following along, it shouldn't be too hard to realize that you do the exact same thing with the bottom footer.

Look for the following code just below the code above in the same file:

Code: Select all
$kdesign['bottom'] = '

      switch($this->style)
      {
         case 0:
            echo \'</td><td valign="top" align="left" width="30%">\';
            infobox();
                    echo \'</td></tr></table>\';
            break;
      
         case 1:
            echo \'</td></tr></table>\';
            break;
      }';


And replace it with this code:

Code: Select all
$kdesign['bottom'] = '

      switch($this->style)
      {
         case 0:
            echo \'</td><td valign="top" align="left" width="30%">\';
            infobox();
        echo $cfg["bottomfooter"];
            echo \'</td></tr></table>\';
            break;
      
         case 1:
        echo $cfg["bottomfooter"];
            echo \'</td></tr></table>\';
            break;
      }';


But where are the <? ?> commands at in the bottom code? Well... they aren't needed here because the bottom code is direct PHP whereas the top code is intermixed PHP/HTML.

Now just one more quick change to make... in order to use these, you have to make sure that the functions that display the top and bottom code recognize the $cfg[] variable or everything you've done so far will be for nought... so... look in the styles.php file or again just look for the following code in the single php:

Code: Select all
   function top()
   {      
      eval(gethtml('top'));      
   }

   function bottom()
   {
    eval(gethtml('bottom'));
   }


And replace it with the following code:

Code: Select all
   function top()
   {      
    global $cfg;
      eval(gethtml('top'));      
   }

   function bottom()
   {
      global $cfg;
    eval(gethtml('bottom'));
   }


Note... the only thing you're adding to these to little functions is the command global $cfg; which basically tells that function that there's something actually in the $cfg variable and to use the contents of it instead of treating it as a new variable entirely.

Well that about does it for the day... You should now be able to change the Header and Footer code to anything you like... a graphic banner, a scrolling text... whatever your heart desires. I hope this helps... lemme know! Does this help Aba?

-=> Satyr! <=-
lrdsatyr8
 
Posts: 4
Joined: Sat Jul 01, 2006 2:40 am

Postby emz » Wed May 23, 2007 9:02 pm

It's not working in my site.
emz
 
Posts: 16
Joined: Wed May 23, 2007 2:35 pm
Location: Bulgaria, Varna


Return to Tips and tricks



cron