Kryptronic Software Support Forum

You are viewing this forum as a guest. Login to an existing account, or create a new account, to reply to topics and to create new topics.

#1 02-09-2011 18:30:16

jensme
Member
Registered: 04-29-2010
Posts: 392

Show all applicable categories in product detail page?

My site is kind of confusing.  All products fall into multiple categories.  I want to be able to show and link to the other categories that each product falls in.  How would I do that?

Offline

 

#2 02-09-2011 18:36:29

jensme
Member
Registered: 04-29-2010
Posts: 392

Re: Show all applicable categories in product detail page?

In fact, I could set it up so there are top categories and list something like:

Occasion: (all are links) Birthday, Anniversary, Christmas
Recipient: (all are links) Family, Friends, Anyone
Etc...

Last edited by jensme (02-10-2011 11:03:57)

Offline

 

#3 02-10-2011 12:59:59

jensme
Member
Registered: 04-29-2010
Posts: 392

Re: Show all applicable categories in product detail page?

Here's what I have so far, but it's looping weird.  IT keeps looping back to categories every time I click on a product:

Code:

<?php

// +--
// | Get variables we need to draw this display.
// +--

$ns       = $this->globals('core.namespace');
$eol      = $this->globals('core.eol');
$proddisp = $this->globals('ecom.prod_proddetail');
$xid      = $proddisp['id'];
$id       = $this->xhtml_encode($xid);
//$usethumb = $this->globals('core_settings.ecom.imguseprodthumb');
//$imgwidthth = $this->globals('core_settings.ecom.imgsizeprodlgth');
$usethumb = '0';
$imgwidthth = '50';
$catdisp  = $this->globals('ecom.cat_catdisp');

// +--
// | Create the tags name and link.
// +--

$catname  = $this->xhtml_encode($catdisp['name']);
$catlink  = $this->link_namespace('ecom','catshow',$catdisp['id']);
$tags     = $proddisp['xcat'];
$cattag   = '';


    $cattag   .= '<script type="text/javascript">' . $eol;
    $cattag   .= '<!--' . $eol;
    $cattag   .= 'if(document.links) { // create an array of catlinks' . $eol;
    $cattag   .= 'var links = new Array();' . $eol;

foreach ($tags as $num => $cat) {

    $cattag   .= 'links[' . $num . '] = new Link();' . $eol;
    $cattag   .= '<a href="' . $catlink . '"><?php print $catname; ?></a>, ';

      } // End of if statement.

} // End of foreach statement.


// +---
// | END TAGS
// +---


if ($ns == 'addcart') {$ns = 'prodshow';}

// +---
// | SLP edited
// +---

if ($ns == 'addinvitembuild'){$ns = 'prodshow';}

$prodtype = $this->xhtml_encode($proddisp['prodtype']);
$prodnum = $this->xhtml_encode($proddisp['prodnum']);

$proddet  = $proddisp['proddet'];
$minibio  = $proddisp['minibio'];
$proddesc_intro  = $proddisp['proddesc_intro'];

//+----------------

$this->globals('ecom.prod_proddisp',$proddisp);
$this->globals('ecom.prod_priceinfo',$proddisp['core.priceinfo']);


// +--
// | Create the product name and description.
// +--

$prodname  = $this->xhtml_encode($proddisp['name']);
$proddesc  = $proddisp['desclong'];
$desc_has_tags = $this->has_tags($proddesc);
if (empty($desc_has_tags)) {$proddesc = '<p>' . $this->xhtml_encode($proddesc) . '</p>';}

if (empty($proddesc)) {

     $proddesc = $proddisp['descshort'];
     $desc_has_tags  = 0;

} // End of if statement.

if (empty($desc_has_tags)) {$proddesc = '<p>' . $this->xhtml_encode($proddesc) . '</p>';}

// +--
// | Create the image tag(s).
// +--

$imglistlg  = $proddisp['imglg'];

if (empty($imglistlg)) {$imglistlg = 'none.png';}

$imglistlg  = $this->make_list($imglistlg);
$imgwidth = $this->globals('core_settings.ecom.imgsizeprodlg');
$imgtag   = '';

if (empty($imgwidth)) {$imgwidth = 180;}

$count   = 0;
$multilg = 0;

foreach ($imglistlg as $num => $name) {
    if ($count == 0) { $lgimname = $name; }

    $count++;
} // End of foreach statement.

if ($count > 1) {
  // We have multi large images.
  $multilg = 0;
      
} // End of if statement.

if (($multilg) && ($usethumb)) {
    $imgtag   .= '<script type="text/javascript">' . $eol;
    $imgtag   .= '<!--' . $eol;
    $imgtag   .= 'if(document.images) { // create an array of prodImages' . $eol;
    $imgtag   .= 'document.prodImages = new Array();' . $eol;

}

foreach ($imglistlg as $num => $img) {

     if (($multilg) && ($usethumb)) {
        $imgurl   = 'media/ecom/prodlg/' . $img;
        $imgtag   .= 'document.prodImages[' . $num . '] = new Image();' . $eol;
        $imgtag   .= 'document.prodImages[' . $num . '].src = "' . $imgurl . '";' . $eol;
        $imgtag   .= 'document.prodImages[' . $num . '].pop = "' . $imgurl . '";' . $eol;
      } else {
          $imgurl   = 'media/ecom/prodlg/' . $img;

         $imgtag   .= '<a class="thumbnail" href="#thumb"><img src="' . $imgurl . '" width="180" alt="' . $prodname . '"><span><img src="' . $imgurl . '" width="400"/></a></span>';

      } // End of if statement.

} // End of foreach statement.

if (($multilg) && ($usethumb)) {
    $imgtag   .= '//-->' . $eol;
    $imgtag   .= '}' . $eol;
    $imgtag   .= '</script>' . $eol;
    $imgurl   = 'media/ecom/prodlg/' . $lgimname;

    $imgtag   .= '<img src="' . $imgurl . '" ';
     if ($imgwidth) {$imgtag .= 'width="180" ';}
    $imgtag  .= 'alt="' . $prodname . '"  id="prodImage" border="0" />';

} // End of if statement.

// +--
// | Print the display.
// +--

?>










<!-- ///// BEGIN PRINT AREA ///// -->











<!-- IMAGES, PRICE, ADD  -->

<div id="blockit" style="height: 240px; width: 995px;">

<div id="images">
<?php print $imgtag; ?>
</div>

<div id="priceplus">
<?php $this->include_file('ecom','pricedisp.php'); ?>

<?php 

// +--
// | Print the product options if we can add the item to the 
// | shopping cart or wish list and we're on the prodshow
// | namespace.
// +--

$add_ok = 1;

if (($proddisp['useinv']) && (!($proddisp['invlevel'] > 0))) {$add_ok = 0;}
if ($proddisp['pricestatus'] == 'D') {$add_ok = 0;}

if (($ns == 'prodshow') && ($add_ok)) {

     print '<p class="ultablesp">&nbsp;</p>' . $eol . $eol;

     $this->include_namespace('ecom','prodshowopt',array());

} // End of if statement.

?>




</div> <!-- END PRICEPLUS -->
</div> <!-- END BLOCKIT -->

<!-- TITLE, DETAILS -->


<div id="blockit">

   <div id="prodtitle">
   <?php print $prodname; ?>
   </div>

   <div id="minidetails">
   <?php print $prodtype; ?>, #<?php print $prodnum; ?>
   </div>

</div>

<!-- DESCRIPTION, ABOUT, TAGS -->

<div id="blockit">

   <div id="description"><?php print $proddesc; ?></div>
   <div id="about"><?php print $proddet; ?></div>
   <div id="tags">Tags<br/> <br/>
      Occasion: [automated]<br/>
      Recipient: Mom, Dad, Brother, Sister, Family, Friends, Strangers<br/>
      Attitude: Nice, Sarcastic, Clever<br/><br/>




<a href="<?php print $catlink; ?>" title="<?php print $catname; ?>"><?php print $catname; ?></a>

</div>

</div>

<!-- <table id="proddetail--<?php print $id; ?>"  cellspacing="0" cellpadding="10" style="width: 100%;">
<tr style="text-align: left;"><td>-->

Offline

 

#4 02-10-2011 13:43:54

jensme
Member
Registered: 04-29-2010
Posts: 392

Re: Show all applicable categories in product detail page?

Now it's not looping, but the categories aren't showing up.  I guess I don't know how to call up the xcat field in the database and... help this thing along.  Thoughts?  I'll pay anyone who helps.

Code:

<?php

// +--
// | Get variables we need to draw this display.
// +--

$ns       = $this->globals('core.namespace');
$eol      = $this->globals('core.eol');
$proddisp = $this->globals('ecom.prod_proddetail');
$xid      = $proddisp['id'];
$id       = $this->xhtml_encode($xid);
//$usethumb = $this->globals('core_settings.ecom.imguseprodthumb');
//$imgwidthth = $this->globals('core_settings.ecom.imgsizeprodlgth');
$usethumb = '0';
$imgwidthth = '50';
$catdisp  = $this->globals('ecom.cat_catdisp');

// +--
// | Create the tags name and link.
// +--

$catname  = $this->xhtml_encode($catdisp['name']);
$catlink  = $this->link_namespace('ecom','catshow',$catdisp['id']);
$tags     = $proddisp['xcat'];
$cattag   = '';


    $cattag   .= '<script type="text/javascript">' . $eol;
    $cattag   .= 'var links = new Array();' . $eol;

foreach ($tags as $num => $cat) {

    $cattag   .= 'links[' . $num . '] = ' . $catname . '>' . $eol;
    $cattag   .= 'var linkURL = new Array();' . $eol;
    $cattag   .= 'linkURL[' . $num . '] = http://www.shopflytrap.com/ecom-catshow/' . $catlink . '>' . $eol;

    $cattag   .= 'for (i=0; i<links.length; i++) {// create an array of catlinks' . $eol;
    $cattag   .= 'document.write("<li>"+links[i].link(linkURL[i])+"</li>");' . $eol;
    $cattag   .= '}' . $eol;
    $cattag   .= '</script>' . $eol;

} // End of foreach statement.



// +---
// | END TAGS
// +---


if ($ns == 'addcart') {$ns = 'prodshow';}

// +---
// | SLP edited
// +---

if ($ns == 'addinvitembuild'){$ns = 'prodshow';}

$prodtype = $this->xhtml_encode($proddisp['prodtype']);
$prodnum = $this->xhtml_encode($proddisp['prodnum']);

$proddet  = $proddisp['proddet'];
$minibio  = $proddisp['minibio'];
$proddesc_intro  = $proddisp['proddesc_intro'];

//+----------------

$this->globals('ecom.prod_proddisp',$proddisp);
$this->globals('ecom.prod_priceinfo',$proddisp['core.priceinfo']);


// +--
// | Create the product name and description.
// +--

$prodname  = $this->xhtml_encode($proddisp['name']);
$proddesc  = $proddisp['desclong'];
$desc_has_tags = $this->has_tags($proddesc);
if (empty($desc_has_tags)) {$proddesc = '<p>' . $this->xhtml_encode($proddesc) . '</p>';}

if (empty($proddesc)) {

     $proddesc = $proddisp['descshort'];
     $desc_has_tags  = 0;

} // End of if statement.

if (empty($desc_has_tags)) {$proddesc = '<p>' . $this->xhtml_encode($proddesc) . '</p>';}

// +--
// | Create the image tag(s).
// +--

$imglistlg  = $proddisp['imglg'];

if (empty($imglistlg)) {$imglistlg = 'none.png';}

$imglistlg  = $this->make_list($imglistlg);
$imgwidth = $this->globals('core_settings.ecom.imgsizeprodlg');
$imgtag   = '';

if (empty($imgwidth)) {$imgwidth = 180;}

$count   = 0;
$multilg = 0;

foreach ($imglistlg as $num => $name) {
    if ($count == 0) { $lgimname = $name; }

    $count++;
} // End of foreach statement.

if ($count > 1) {
  // We have multi large images.
  $multilg = 0;
      
} // End of if statement.

if (($multilg) && ($usethumb)) {
    $imgtag   .= '<script type="text/javascript">' . $eol;
    $imgtag   .= '<!--' . $eol;
    $imgtag   .= 'if(document.images) { // create an array of prodImages' . $eol;
    $imgtag   .= 'document.prodImages = new Array();' . $eol;

}

foreach ($imglistlg as $num => $img) {

     if (($multilg) && ($usethumb)) {
        $imgurl   = 'media/ecom/prodlg/' . $img;
        $imgtag   .= 'document.prodImages[' . $num . '] = new Image();' . $eol;
        $imgtag   .= 'document.prodImages[' . $num . '].src = "' . $imgurl . '";' . $eol;
        $imgtag   .= 'document.prodImages[' . $num . '].pop = "' . $imgurl . '";' . $eol;
      } else {
          $imgurl   = 'media/ecom/prodlg/' . $img;

         $imgtag   .= '<a class="thumbnail" href="#thumb"><img src="' . $imgurl . '" width="180" alt="' . $prodname . 

'"><span><img src="' . $imgurl . '" width="400"/></a></span>';

      } // End of if statement.

} // End of foreach statement.

if (($multilg) && ($usethumb)) {
    $imgtag   .= '//-->' . $eol;
    $imgtag   .= '}' . $eol;
    $imgtag   .= '</script>' . $eol;
    $imgurl   = 'media/ecom/prodlg/' . $lgimname;

    $imgtag   .= '<img src="' . $imgurl . '" ';
     if ($imgwidth) {$imgtag .= 'width="180" ';}
    $imgtag  .= 'alt="' . $prodname . '"  id="prodImage" border="0" />';

} // End of if statement.

// +--
// | Print the display.
// +--

?>










<!-- ///// BEGIN PRINT AREA ///// -->











<!-- IMAGES, PRICE, ADD  -->

<div id="blockit" style="height: 240px; width: 995px;">

<div id="images">
<?php print $imgtag; ?>
</div>

<div id="priceplus">
<?php $this->include_file('ecom','pricedisp.php'); ?>

<?php 

// +--
// | Print the product options if we can add the item to the 
// | shopping cart or wish list and we're on the prodshow
// | namespace.
// +--

$add_ok = 1;

if (($proddisp['useinv']) && (!($proddisp['invlevel'] > 0))) {$add_ok = 0;}
if ($proddisp['pricestatus'] == 'D') {$add_ok = 0;}

if (($ns == 'prodshow') && ($add_ok)) {

     print '<p class="ultablesp">&nbsp;</p>' . $eol . $eol;

     $this->include_namespace('ecom','prodshowopt',array());

} // End of if statement.

?>




</div> <!-- END PRICEPLUS -->
</div> <!-- END BLOCKIT -->

<!-- TITLE, DETAILS -->


<div id="blockit">

   <div id="prodtitle">
   <?php print $prodname; ?>
   </div>

   <div id="minidetails">
   <?php print $prodtype; ?>, #<?php print $prodnum; ?>
   </div>

</div>

<!-- DESCRIPTION, ABOUT, TAGS -->

<div id="blockit">

   <div id="description"><?php print $proddesc; ?></div>
   <div id="about"><?php print $proddet; ?></div>
   <div id="tags">Tags<br/> <br/>
      Occasion: [automated]<br/>
      Recipient: Mom, Dad, Brother, Sister, Family, Friends, Strangers<br/>
      Attitude: Nice, Sarcastic, Clever<br/><br/>




<a href="<?php print $catlink; ?>" title="<?php print $catname; ?>"><?php print $catname; ?></a>

</div>

</div>

<!-- <table id="proddetail--<?php print $id; ?>"  cellspacing="0" cellpadding="10" style="width: 100%;">
<tr style="text-align: left;"><td>-->

Here's the page I'm working with.  Please ignore the screwed up images for a moment:

http://www.shopflytrap.com/ecom-prodshow/TEST001.html

Last edited by jensme (02-10-2011 13:49:28)

Offline

 

#5 02-10-2011 14:00:49

KryptoJim
Member
Registered: 07-08-2010
Posts: 455

Re: Show all applicable categories in product detail page?

I don't believe any of those category variables are defined there.  You're going to need to call them.

Also, you can't use foreach against a comma separated list.  You're going to need to split that up into an array.

Offline

 

#6 02-10-2011 14:18:23

jensme
Member
Registered: 04-29-2010
Posts: 392

Re: Show all applicable categories in product detail page?

Thanks.  I removed the foreach in the second version because I don't need it. I don't think... I'm following this:

function linkDisplay() {
  /* Enter the link name below. Each entry must have
     a unique number in the "[]" brackets. */
  var links = new Array();
    links[0]="Google";
    links[1]="Yahoo";
    links[2]="Web Reference";
    links[3]="JavaScript Forum";

  var linkURL = new Array();
    linkURL[0]="http://www.google.com";
    linkURL[1]="http://www.yahoo.com";
    linkURL[2]="http://www.webreference.com";
    linkURL[3]="http://www.webdeveloper.com/forum/forumdisplay.php?f=3";

  for (i=0; i<links.length; i++) {
    document.write("<li>"+links[i].link(linkURL[i])+"</li>");
  }
}

Offline

 

#7 02-11-2011 00:34:20

vbsaltydog
Member
From: Florida
Registered: 05-02-2005
Posts: 947
Website

Re: Show all applicable categories in product detail page?

Without reading all of your code, why are you using php to generate javascript to do a document.write in the browser when php has the print function?


Latest CCP 7 XMods Available:


Offline

 

#8 02-11-2011 09:58:09

jensme
Member
Registered: 04-29-2010
Posts: 392

Re: Show all applicable categories in product detail page?

Hell if I know!  big_smile  Honestly, I'm a hack with all code and learn by looking at other people's code.  I don't know what goes with what, what conflicts with what, etc.  It's just a crapshoot with me.

Offline

 

#9 02-11-2011 10:59:18

jensme
Member
Registered: 04-29-2010
Posts: 392

Re: Show all applicable categories in product detail page?

To be more clear, I was stealing the code that creates the image list in the product detail display.  That seems to be JS.

Offline

 

Board footer