Zen Cart Logo

sidebox problem...

Views: 1,076

Results 1 to 14 of 14
24 Jan 2011, 4:54 PM
#1
mikestaps avatar

mikestaps

Zen Follower

Join Date:
Aug 2010
Location:
Grand Blanc, MI
Posts:
305
Plugin Contributions:
1

sidebox problem...

I am attempting to "create" a sidebox by editing a mod designed for the header. I have it showing up but my new side box auto fill with the content of whatever sidebox is above it and prints the desired content below the box.

I haven't been able to figure this one out:frusty:

store is here

Any help is greatly appreciated, thx

24 Jan 2011, 4:58 PM
#2
keneso avatar

keneso

Totally Zenned

Join Date:
May 2009
Posts:
1,273
Plugin Contributions:
3

Re: sidebox problem...

Why don't you use blank sidebox mod instead the one for the header??

24 Jan 2011, 5:23 PM
#3
coolcarpartsonline avatar

coolcarpartsonline

Totally Zenned

Join Date:
Feb 2008
Posts:
1,386
Plugin Contributions:
0

Re: sidebox problem...

You should arrange the code in a sidebox form. You can't just take a block of code that has a 700px width and drop it in a sidebox and expect it to rearrange itself. This is just an example but you should arrange the code based on a proper sidebox logic.

24 Jan 2011, 6:13 PM
#4
mikestaps avatar

mikestaps

Zen Follower

Join Date:
Aug 2010
Location:
Grand Blanc, MI
Posts:
305
Plugin Contributions:
1

Re: sidebox problem...

keneso:

Why don't you use blank sidebox mod instead the one for the header??
I will give it a try using the blank as my template. The mod I am trying to get to the sidebox is this one - product finder

CoolCarPartsOnline:

You should arrange the code in a sidebox form. You can't just take a block of code that has a 700px width and drop it in a sidebox and expect it to rearrange itself. This is just an example but you should arrange the code based on a proper sidebox logic.

This is where I get lost....
I am not using any of the orig css for the product finder, so I was hoping the width wouldn't be an issue.

24 Jan 2011, 6:56 PM
#5
mikestaps avatar

mikestaps

Zen Follower

Join Date:
Aug 2010
Location:
Grand Blanc, MI
Posts:
305
Plugin Contributions:
1

Re: sidebox problem...

being a newbie to php coding I have ask "one of those" questions...

for the content of the sidebox I want to use php,
so I would take this line of php code (for example):
echo "<li>";
and make it:
$content .= 'echo "<li>"';
or
$content .= 'echo "<li>";';

thx

24 Jan 2011, 8:04 PM
#6
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: sidebox problem...

To add <li> to the output content variable, you would use

$content .= '<li>';

echo "<li>"; outputs the <li> to the page immediately, which is bad if the code hasn't sent the HTML <head> info yet.

24 Jan 2011, 8:41 PM
#7
mikestaps avatar

mikestaps

Zen Follower

Join Date:
Aug 2010
Location:
Grand Blanc, MI
Posts:
305
Plugin Contributions:
1

Re: sidebox problem...

gjh42:

To add <li> to the output content variable, you would use

$content .= '<li>';

echo "<li>"; outputs the <li> to the page immediately, which is bad if the code hasn't sent the HTML <head> info yet.

ok, good to know, thx

24 Jan 2011, 9:55 PM
#8
mikestaps avatar

mikestaps

Zen Follower

Join Date:
Aug 2010
Location:
Grand Blanc, MI
Posts:
305
Plugin Contributions:
1

Re: sidebox problem...

Ok I'm sure this is absurdly easy but I'm it's giving me :censored:!

This is the code I am trying to put into the side box -

<?php 
	 echo "<form action=''>";			
?>
    <ul class="navMain">
      <?php
   echo "<li>";
   $model1[]=array('id'=>'','text'=>TEXT_PLEASE_SELECT);
	 if(isset($_REQUEST['cPath1'])){
	 $value=$_REQUEST['cPath1'];
	 }	 
	 echo '<span id="pf_title">'.strip_tags(TEXT_FIND_ALL_PRODUCTS).'</span>
	 <span class="pf_selectbox_name">'.TEXT_MAKE . '</span>' . zen_draw_pull_down_menu('cPath1',array_merge($model1,zen_get_category_tree()),$value, 'id="cPath" class="pf_selectbox_text"'); 
	 echo "</li>\n";
   
	echo '<li>';   
	echo '<noscript>';
echo zen_my_image_submit(PF_NOSCRIPT_SUBMIT, 'Go');
         if($_REQUEST['cPath1']!=""){
               $value=$_REQUEST['cPath1'];
			   $dropdownArray=zen_get_category_tree($value);
         }
echo "</noscript>";
 echo "</li>\n";    

echo "<li>";
	  $modulePath="".DIR_WS_CATALOG;
	  echo zen_draw_hidden_field('basemodulepath',$modulePath,'id="basemodulepath" ');
	 $model=array();
	 $model[]=array('id'=>'',
	                 'text'=>TEXT_PLEASE_SELECT
					 );
	   if($_REQUEST['cPath1']!=""){
	    $model=array_merge($model,$dropdownArray);
	    }
	if(isset($_REQUEST['select_model'])){
	$value=$_REQUEST['select_model'];
	}
	 echo '<span class="pf_selectbox_name">' . TEXT_MODEL .'</span>' 
	 . zen_draw_pull_down_menu('select_model', $model, $value, 'id="select_model" class="pf_selectbox_text"'); 
 echo "</li>\n";

echo "<li>";
echo "<noscript>";
if($_REQUEST['select_model']!=""){
               $value=$_REQUEST['select_model'];
			   $dropdownArray=zen_get_category_tree($value); 
         }
echo zen_my_image_submit(PF_NOSCRIPT_SUBMIT, 'Go');	 
echo "</noscript>";
 echo "</li>\n";

echo "<li>";
	 $year=array();
	 $year[]=array('id'=>'',
	                 'text'=>TEXT_PLEASE_SELECT
					 );
	  if($_REQUEST['select_model']!=""){
	    $year=array_merge($year,$dropdownArray);
	    }				 				 
if(isset($_REQUEST['cPath'])){
          $value=$_REQUEST['cPath'];
}
if($_REQUEST['select_model']!=""){
	 echo '<span class="pf_selectbox_name">' . TEXT_YEAR . '</span>' . 
	 zen_draw_pull_down_menu('cPath',$year , $value, 'id="select_year" class="pf_selectbox_text"');
	 }
else {
	 echo '<span class="pf_selectbox_name">' . TEXT_YEAR .'</span>' .
	 zen_draw_pull_down_menu('cPath22',$year , $value, 'id="select_year" class="pf_selectbox_text"');
}	 
echo "</li>\n";

echo "<li>";
echo "<noscript>";
if($_REQUEST['cPath']!=""){
         $value=$_REQUEST['cPath'];
	     }
echo zen_my_image_submit(PF_NOSCRIPT_SUBMIT, 'Go');
echo "</noscript>";
 echo "</li>\n";
?>
    </ul>
    </form>

I changed the code to this and the page stops loading when it should load this -

<?php
/**
 * blank sidebox - allows a blank sidebox to be added to your site
 *
 * @package templateSystem
 * @copyright 2007 Kuroi Web Design
  * @copyright Portions Copyright 2003-2007 Zen Cart Development Team
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: blank_sidebox.php 2007-05-26 kuroi $
 */

  $content = '';
  $content .= '<div id="' . str_replace('_', '-', $box_id . 'Content') . '" class="sideBoxContent">';

  // Replace the text and HTML tags between the apostophes on lines 19 and 20.
  // Use as many or as few lines using this model as you need for your custom content.
  // If you have a multilingual site define your text in the languages/YOUR_LANGUAGE/extra_definitions/blank_sidebox_defines.php and include it as shown in line 19.
  // If your site is monolingual, you can put the text right here as shown on line 20 (and nobody will know!)
  // $content .= '<p>' . TEXT_BLANK_SIDEBOX . '</p>';
 
  $content .= 'echo "<form action=''>"';			
  $content .= '<ul class="navMain">';
  $content .= '<li>';
  $content .= '($model1[]=array('id'=>'','text'=>TEXT_PLEASE_SELECT); if(isset($_REQUEST['cPath1'])){$value=$_REQUEST['cPath1'];})';	 
	 
  $content .= '<span class="pf_selectbox_name">'.TEXT_MAKE . '</span>' . zen_draw_pull_down_menu('cPath1',array_merge($model1,zen_get_category_tree()),$value, 'id="cPath" class="pf_selectbox_text"')';
   
  $content .= '</li>'; 
  $content .= '<li>';
  $content .= '$modulePath="".DIR_WS_CATALOG';
  $content .= 'echo zen_draw_hidden_field('basemodulepath',$modulePath,'id="basemodulepath" ')';
	 $content .= '$model=array()';
	 $content .= '($model[]=array('id'=>'',
	                 'text'=>TEXT_PLEASE_SELECT
					 );
	   if($_REQUEST['cPath1']!=""){
	    $model=array_merge($model,$dropdownArray);
	    }
	if(isset($_REQUEST['select_model'])){
	$value=$_REQUEST['select_model'];
	})';
	 $content .= 'echo '<span class="pf_selectbox_name">' . TEXT_MODEL .'</span>' 
	 . zen_draw_pull_down_menu('select_model', $model, $value, 'id="select_model" class="pf_selectbox_text"')'; 
 $content .= '</li>';

$content .= '<li>';

	 $content .= '$year=array()';
	 $content .= '($year[]=array('id'=>'',
	                 'text'=>TEXT_PLEASE_SELECT
					 );
	  if($_REQUEST['select_model']!=""){
	    $year=array_merge($year,$dropdownArray);
	    }				 				 
if(isset($_REQUEST['cPath'])){
          $value=$_REQUEST['cPath'];
}
if($_REQUEST['select_model']!=""){
	 echo '<span class="pf_selectbox_name">' . TEXT_YEAR . '</span>' . 
	 zen_draw_pull_down_menu('cPath',$year , $value, 'id="select_year" class="pf_selectbox_text"');
	 }
else {
	 echo '<span class="pf_selectbox_name">' . TEXT_YEAR .'</span>' .
	 zen_draw_pull_down_menu('cPath22',$year , $value, 'id="select_year" class="pf_selectbox_text"');
})';	 
$content .= '</li>';

 $content .= '</li>';

    $content .= '</ul>';
    $content .= '</form>';

  $content .= '</div>';
?>

for now I'm off to the wild web to see what else I can learn about php coding... prolly just enuf to get myself into trouble!

24 Jan 2011, 10:06 PM
#9
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: sidebox problem...

$content .= 'echo "<form action=''>"';

This has a couple of problems.
You don't use echo as part of the content of a PHP string variable - it is only for making immediate output. This will just not work as desired, and possibly cause an HTML error in the page.

The first of the two single quotes in action='' will be interpreted by PHP as closing the string opened by 'echo, and then another single quote without intervening operators will cause a PHP error.

$content .= '<form action="">';
25 Jan 2011, 8:07 PM
#10
mikestaps avatar

mikestaps

Zen Follower

Join Date:
Aug 2010
Location:
Grand Blanc, MI
Posts:
305
Plugin Contributions:
1

Re: sidebox problem...

gjh42-
Thanks for the direction but unfortunately...
Another attempt = another fail!:oops:

$content = '';
  $content .= '<div id="' . str_replace('_', '-', $box_id . 'Content') . '" class="sideBoxContent">';
  //$content .= '<p>' . TEXT_BLANK_SIDEBOX . '</p>';
  $content .= '<form action="">';			
  $content .= '<ul>';
  $content .= '<li>';
  $content .= $model1[]=array('id'=>'','text'=>TEXT_PLEASE_SELECT) . if(isset($_REQUEST['cPath1'])){$value=$_REQUEST['cPath1'];};	 
  $content .= '<span class="pf_selectbox_name">' . TEXT_MAKE . '</span>' . zen_draw_pull_down_menu('cPath1',array_merge($model1,zen_get_category_tree()),$value, 'id="cPath" class="pf_selectbox_text"');
  $content .= '</li>\n'; 
  $content .= '<li>';
  $content .= $modulePath="".DIR_WS_CATALOG;
  $content .= zen_draw_hidden_field('basemodulepath',$modulePath,'id="basemodulepath" ');
  $content .= $model=array();
  $content .= $model[]=array('id'=>'' , 'text'=>TEXT_PLEASE_SELECT); . if($_REQUEST['cPath1']!=""){$model=array_merge($model,$dropdownArray);} . if(isset($_REQUEST['select_model'])){$value=$_REQUEST['select_model'];};
  $content .=  '<span class="pf_selectbox_name">' . TEXT_MODEL .'</span>' . zen_draw_pull_down_menu('select_model', $model, $value, 'id="select_model" class="pf_selectbox_text"'); 
  $content .= '</li>\n';
  $content .= '<li>';
  $content .= $year=array();
  $content .= $year[]=array('id'=>'','text'=>TEXT_PLEASE_SELECT) . if($_REQUEST['select_model']!=""){$year=array_merge($year,$dropdownArray);} . if(isset($_REQUEST['cPath'])){$value=$_REQUEST['cPath'];} . if($_REQUEST['select_model']!=""){'<span class="pf_selectbox_name">' . TEXT_YEAR . '</span>' . zen_draw_pull_down_menu('cPath',$year , $value, 'id="select_year" class="pf_selectbox_text"');} . else {'<span class="pf_selectbox_name">' . TEXT_YEAR .'</span>' . zen_draw_pull_down_menu('cPath22',$year , $value, 'id="select_year" class="pf_selectbox_text"');});	 
  $content .= '</li>\n';
  $content .= '</ul>';
  $content .= '</form>';
  $content .= '</div>';

I'm guessing that the issue is now in the if statements... but that's just a guess.

25 Jan 2011, 8:37 PM
#11
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: sidebox problem...

Okay... actually reading through what you have done, it is basically totally messed up. You do not assign PHP if statements and other code to a $content variable; you run those statements and assign the output from their results to $content where applicable.
I'm not going to do it all here, but this is a sample of how to handle it:```php

<?php echo "<form action=''>"; ?>
<ul class="navMain">
  <?php

echo "<li>";
$model1[]=array('id'=>'','text'=>TEXT_PLEASE_SELECT);
if(isset($_REQUEST['cPath1'])){
$value=$_REQUEST['cPath1'];
}
echo '<span id="pf_title">'.strip_tags(TEXT_FIND_ALL_PRODUCTS).'</span>
<span class="pf_selectbox_name">'.TEXT_MAKE . '</span>' . zen_draw_pull_down_menu('cPath1',array_merge($model1,zen_get_category_tree()),$value, 'id="cPath" class="pf_selectbox_text"');
echo "</li>\n";

echo '<li>';   
echo '<noscript>';

echo zen_my_image_submit(PF_NOSCRIPT_SUBMIT, 'Go');
if($_REQUEST['cPath1']!=""){
$value=$_REQUEST['cPath1'];
$dropdownArray=zen_get_category_tree($value);
}
echo "</noscript>";
echo "</li>\n";

// etc

<?php 
$content = '<form action="">';			
$content .= '<ul class="navMain">' . "\n" . '<li>';
  $model1[]=array('id'=>'','text'=>TEXT_PLEASE_SELECT);
    if(isset($_REQUEST['cPath1'])){
      $value=$_REQUEST['cPath1'];
    }	 
    $content .= '<span id="pf_title">'.strip_tags(TEXT_FIND_ALL_PRODUCTS).'</span><span class="pf_selectbox_name">'.TEXT_MAKE . '</span>' . zen_draw_pull_down_menu('cPath1',array_merge($model1,zen_get_category_tree()),$value, 'id="cPath" class="pf_selectbox_text"'); 
    $content .= "</li>\n";
   
    $content .= '<li>';   
    $content .= '<noscript>';
    $content .= zen_my_image_submit(PF_NOSCRIPT_SUBMIT, 'Go');
    if($_REQUEST['cPath1']!=""){
      $value=$_REQUEST['cPath1'];
      $dropdownArray=zen_get_category_tree($value);
    }
    $content .=  "</noscript>";
    $content .=  "</li>\n";    

// etc
```
Essentially, replace any echo with $content .= leaving the rest of the code pretty much as is.

HTML output outside of <?php ?> tags needs to be added to $content, wrapping it in single quotes and ending with a ;
25 Jan 2011, 8:43 PM
#12
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: sidebox problem...

Erratum: Since $content has already been initialized earlier in the file, you would not do this

$content = '<form action="">';

but this

$content .= '<form action="">';

25 Jan 2011, 10:41 PM
#13
mikestaps avatar

mikestaps

Zen Follower

Join Date:
Aug 2010
Location:
Grand Blanc, MI
Posts:
305
Plugin Contributions:
1

Re: sidebox problem...

Thank you so much, a even larger step in the right direction... I'll get right to work! :clap:

25 Jan 2011, 11:02 PM
#14
mikestaps avatar

mikestaps

Zen Follower

Join Date:
Aug 2010
Location:
Grand Blanc, MI
Posts:
305
Plugin Contributions:
1

Re: sidebox problem...

IT WORKED!!!! Thank you so much! :cheers: Now I just have to play with the css and it's good to go! :thumbsup: