Zen Cart Logo
Forums / Setting Up Categories, Products, Attributes / Product Type Book (by moku)

Product Type Book (by moku)

Views: 203,541

Results 621 to 640 of 647
25 Nov 2010, 12:33 AM
#621
timryan avatar

timryan

New Zenner

Join Date:
May 2010
Posts:
7
Plugin Contributions:
0

Product Type Book (by moku)

Hey everyone, I've seen a few questions in this forum regarding custom pages that contain lists (and links) of book subjects/genres etc, and not many solutions.

With some tinkering, I've finally got something working, so figured I'd share. The code below is based off the manufacturer list sidebox by Kuroi. It displays the list of genres that are used in your products. It also displays the number of those books etc that contain that genre/subject.

I'm currently using v1.3.9g of Zen Cart and v4 (jph) of Moku's Book mod and it appears to work fine.

To make a list of something else (like Authors..which I might try next) all you have to do (i think) is point the SQL in the code to the relevant database fields.

Hope this helps some people.

<?php
/**
 * genre list page - displays a list of book genres/subjects so the customer can choose to filter on books with those genres only
 * edited by Tim Ryan based on the manufacturer list sidebox by Kuroi 
 * @package templateSystem
 * @copyright Portions Copyright 2007-2009 Kuroi Web Design
 * @copyright Portions Copyright 2003-2006 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 */

// set to true to display a count of the number of products for each genre
define('DISPLAY_GENRES_COUNTS', false);

// debug switch
define('DEBUG_GENRES_SIDEBOX', false);

// test if genres should show
$show_genres = true;

if (DEBUG_GENRES_SIDEBOX) {
  echo "Entering genres module ...<br/>\n";
  echo '- Images: ' . (DISPLAY_GENRES_IMAGES ? 'TRUE' : 'FALSE') . "<br/>\n";
  echo '- Man. Status: ' . PRODUCTS_GENRES_STATUS . "<br/>\n";
  echo '- Counts: ' . (DISPLAY_GENRES_COUNTS ? 'TRUE' : 'FALSE') . "<br/>\n";
  echo '- Show: ' . ($show_genres ? 'TRUE' : 'FALSE') . "<br/><br/>\n";
}

if ($show_genres) {


    // pull counts from the database
    $genre_counts_query = "SELECT book_genre_id, COUNT( products_id ) AS number FROM " . TABLE_BOOKS_TO_GENRES . " WHERE book_genre_id IS NOT NULL AND book_genre_id > 0 GROUP BY book_genre_id";
    $genre_counts_result = $db->Execute($genre_counts_query);

    // prepare counts for use later
    $genre_counts_list = array();
    while (!$genre_counts_result->EOF) {
      $genre_counts_list[$genre_counts_result->fields['book_genre_id']] = $genre_counts_result->fields['number'];
	  $genre_counts_result->MoveNext();
	}
	
	if (DEBUG_GENRES_SIDEBOX) {
	  echo '<h4>List of Counts</h4>';
      echo '<pre>' . "\n";
	  var_dump($genre_counts_list);
	  echo '</pre>' . "\n";
    }


  // now let's get the genres
  $genre_sidebox_query = "SELECT g.book_genre_id, gd.book_genre_name
                                  FROM " . TABLE_BOOK_GENRE . " g, " . TABLE_BOOK_GENRE_DESCRIPTION . " gd
WHERE g.book_genre_id = gd.book_genre_id
                                  ORDER BY gd.book_genre_name";
  $genre_sidebox_result = $db->Execute($genre_sidebox_query);

  if ($genre_sidebox_result->RecordCount() > 0) {

    $genre_sidebox_list = array();

    while (!$genre_sidebox_result->EOF) {

	// prepare data
	  $genre_id = $genre_sidebox_result->fields['book_genre_id'];
      $genre_name = $genre_sidebox_result->fields['book_genre_name'];
	  
      $genre_count = isset($genre_counts_list[$genre_id]) ? (int)$genre_counts_list[$genre_id] : 0;

	if (DEBUG_GENRES_SIDEBOX) {
      echo 'Processing ' . $genre_name . "<br/>\n";
    }
	  
      // add to list only if we are showing all genres, or this one has products
	  if ($genre_count > 0) {
        $genre_sidebox_list[] = array(
          'id' => $genre_id,
          'text' => $genre_name,
          'count' => $genre_count);
      }

      // advance to next result
	  $genre_sidebox_result->MoveNext();
    }

	if (DEBUG_GENRES_SIDEBOX) {
      echo '<br/><h4>Final List</h4>';
      echo '<pre>' . "\n";
	  var_dump($genre_sidebox_list);
	  echo '</pre>' . "\n";
    }
	
	if (sizeof($genre_sidebox_list) > 0 ) {
        $content = '';
  $content .= '<div id="' . str_replace('_', '-', $box_id . 'Content') . '" class="">' . "\n";
  $content .= '<ul>' . "\n";
  foreach ($genre_sidebox_list as $genre) {
    if ($genre['text']!=''){
      $content .= '<li><a class="manufacturerName" href="' . zen_href_link(FILENAME_DEFAULT, 'typefilter=book_genre&book_genre_id=' . $genre['id']) . '">';
      $content .= $genre['text'];
      $content .= '</a>';
      
        $content .= '  (' . $genre['count'] . ')';
      
      $content .= '</li>' . "\n";
    }
  }
  $content .= "</ul>\n</div>\n";

      echo $content;
    }
  }
}
25 Nov 2010, 1:04 PM
#622
dw08gm avatar

dw08gm

Totally Zenned

Join Date:
Sep 2008
Location:
DownUnder, overlooking South Pole.
Posts:
1,017
Plugin Contributions:
2

Re: Product Type Book (by moku)

Hi Tim

Where should your code be inserted?

Thanks

25 Nov 2010, 10:08 PM
#623
timryan avatar

timryan

New Zenner

Join Date:
May 2010
Posts:
7
Plugin Contributions:
0

Re: Product Type Book (by moku)

dw08gm:

Hi Tim

Where should your code be inserted?

Thanks

I created a new custom page, following this guide

http://www.zen-cart.com/wiki/index.php/Creating_new_pages

The code pastes into the includes/templates/template_default/templates/tpl_myNewPage_default.php page

Cheers,

Tim

3 Jan 2011, 5:29 AM
#624
meesh avatar

meesh

New Zenner

Join Date:
Feb 2009
Posts:
28
Plugin Contributions:
0

Re: Product Type Book (by moku)

I have zencart v. 1.3.9h installed.

I am not sure if the current version of Product book type works properly on this version of zencart.

I did install product book type, however when adding a new product I choose "product-book" and click "new product" but I get a 404 page not found error.

I am not well versed in php and I am wondering if there is a problem with the way I installed the mod, or if it simply won't work on my zen cart version.

Any help would be appreciated as I don't even know where to start to trouble shoot this problem.

5 Jan 2011, 3:18 AM
#625
ikanperak avatar

ikanperak

New Zenner

Join Date:
Apr 2009
Posts:
5
Plugin Contributions:
0

Re: Product Type Book (by moku)

I am still using 1.3.8a (with all the security patches). I know I should migrate to 1.3.9h, but my site works fine with one exception: zc search on my site is a pain. But, please don't get me wrong. ZC search is excellent, but I think the problem is my host because search works perfectly on my desktop server( (MAMP).

So why am I writing this?

  1. I think I will need to switch hosts (although I have been with the present guys for years) that works well with ZC. I would appreciate any recommendation. Even better, if there is one that will allow me to test my site on it for a short period before I commit.

  2. Is there anyway I can limit ZC keyword search to book titles and authors only. Searching description only gives me a whole lot of results my customers don't need.

Now, a declaration. I am a geezer who learnt programming in the days of Fortran 4, which would give you an indication of my age. I am not totally out of touch with code; I can more or less make out what it is trying to say by looking at it. Still, it is only a hobby and I envy all the young energy at forums like this.

Enough self-pity.

So I will be happy if someone could respond or at least point me to threads or postings that can help me. (Oh, BTW, I have been searching ZC forums, FAQs and tutorials for answers for several weeks now. The closest I have got is this: http://www.zen-cart.com/forum/showthread.php?t=131747 -- Improving search results.)

8 Jan 2011, 6:37 PM
#626
yosemirza avatar

yosemirza

New Zenner

Join Date:
Aug 2009
Posts:
25
Plugin Contributions:
0

Re: Product Type Book (by moku)

I am suggesting we are who using this Product Type Book contribute together some money to hire a developer to make a clean module, or to improve the latest one. I am not sure how much is the cost, But I think we hire someone in this forum who can do this job.

10 Jan 2011, 6:48 AM
#627
ikanperak avatar

ikanperak

New Zenner

Join Date:
Apr 2009
Posts:
5
Plugin Contributions:
0

Re: Product Type Book (by moku)

Yes, good idea, I will support that.

10 Jan 2011, 10:08 PM
#628
niceshoes avatar

niceshoes

New Zenner

Join Date:
Jan 2011
Posts:
1
Plugin Contributions:
0

Re: Product Type Book (by moku)

pcontente:

Hey Flashy!

It is working with latest LAMPP on UBUNTU 10.10. Latest Zencart either.

I followed exactly the same steps as I've followed with XAMPP on Windows and It worked! Even multi-language! I can insert books in English and some other language and it seems to work quite fine.

The only difference between windows and linux was that I replaced file owners and permissions in linux, i.e, the original owner of the files was pcontente (user with which I decompressed the zip file to my Downloads folder) and I changed it to root. In Windows I did nothing regarding permissions as you know in Windows we're all admins!! :)

I am going to play around with a bit!

Cheers,

Pedro Contente

Hey Flashy / Pedro

I have the same error too (blank page when adding products).

syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in ***\admin\includes\modules\product_book\collect_info.php on line 1766

I'm using WAMP.
It seems us 'windows' users are having this issue.
Can any Windows users confirm they have this working?

Cheers,

Ian

11 Jan 2011, 7:03 AM
#629
yosemirza avatar

yosemirza

New Zenner

Join Date:
Aug 2009
Posts:
25
Plugin Contributions:
0

Re: Product Type Book (by moku)

ikanperak:

Yes, good idea, I will support that.

Is there someone else want to join this?
I am not sure if this allowed to discuss in this forum.

13 Feb 2011, 11:15 PM
#630
rmsimp avatar

rmsimp

New Zenner

Join Date:
Feb 2011
Posts:
14
Plugin Contributions:
0

Re: Product Type Book (by moku)

Hi all I am sure I am missing something but I downloaded book product from post above seem to have gotten only part of the files, the file book_main_file will not let me access it. also in the read me file it says to apply the patch RUN_THIS_FULL_INSTALL_SQL_PATCH_FOR_DATABASE. That file is not in the download. Any help would be great. thanks in advance.
Rick

14 Feb 2011, 4:24 AM
#631
davewest avatar

davewest

Totally Zenned

Join Date:
Dec 2007
Location:
Payson, AZ
Posts:
1,075
Plugin Contributions:
7

Re: Product Type Book (by moku)

yosemirza:

Is there someone else want to join this?
I am not sure if this allowed to discuss in this forum.
I've been looking at this for some time, but had other things on my table. This mod was more of a lesson in creating product types then a working mod... it help point me in the right direction with product type auctions.

Looking at the structure again, I have some questions... In order to create a product type book that would be more inline with the current version of Zen Cart and with the minimum amount of edits when upgrading your cart or when version 2 comes out... I would have to do a total rewrite of the mod.

The downside to this is you would have to do a fresh install... upgrading would not be impossible to do thus this would start a new fork for product type book.

18 Feb 2011, 6:43 PM
#632
rmsimp avatar

rmsimp

New Zenner

Join Date:
Feb 2011
Posts:
14
Plugin Contributions:
0

Re: Product Type Book (by moku)

Can anyone tell me how to change the number of characters that display in Authors search. It worked fine until I added latest upgrade, now I only get first 5 letters and 2 periods for names. Thanks in advance

28 Feb 2011, 5:58 AM
#633
raunharman avatar

raunharman

Zen Follower

Join Date:
Dec 2005
Posts:
165
Plugin Contributions:
0

Re: Product Type Book (by moku)

Where can I get the latest upgrade for Zen 1.39h

1 Apr 2011, 1:36 PM
#634
biscayne avatar

biscayne

New Zenner

Join Date:
Oct 2006
Location:
the Netherlands
Posts:
32
Plugin Contributions:
0

Re: Product Type Book (by moku)

Unfortunately there is no special PTB version for 1.3.9h.
The latest was PTB4 written for ZC 1.3.8
I've PTB2 running on 1.3.9h but have many issues.

2 Apr 2011, 10:58 PM
#635
labaslelikas avatar

labaslelikas

New Zenner

Join Date:
Apr 2011
Posts:
3
Plugin Contributions:
0

Re: Product Type Book (by moku)

Can somebody share a working link to download Book Product Type?
I would appreciate, cause I can't download it from jphuk.co.uk.

Thanks in advance.

12 Apr 2011, 12:31 PM
#636
biscayne avatar

biscayne

New Zenner

Join Date:
Oct 2006
Location:
the Netherlands
Posts:
32
Plugin Contributions:
0

Re: Product Type Book (by moku)

PM me your email addressand I will send you PTB as mail attachment.
Also let me know which version of PTB.

12 Jul 2011, 12:13 PM
#637
raunharman avatar

raunharman

Zen Follower

Join Date:
Dec 2005
Posts:
165
Plugin Contributions:
0

Re: Product Type Book (by moku)

Where do I send a PM . i cannoy find any link.

3 Mar 2012, 1:41 PM
#638
allanh avatar

allanh

New Zenner

Join Date:
Aug 2009
Posts:
1
Plugin Contributions:
0

Re: Product Type Book (by moku)

Can I have a working link for the "BOOK" product type please.

email is [email protected].

Thanks Allan

10 Apr 2012, 12:29 PM
#639
sammirah avatar

sammirah

Zen Follower

Join Date:
Apr 2012
Location:
Los Angeles, CA
Posts:
185
Plugin Contributions:
2

Re: Product Type Book (by moku)

Hi AllanH,

I have been using Product Book Type for about 3 years now. I do not think Moku's site is coming back. But I do have a copy of the zip last upgraded zip file on my server.

Do be forwarned it doesn't work too well with 1.5.0 but I have been able to use it seemlessly with 1.3.9h and earlier. 1.5.0 has it's own version of product book but it is seriously lacking. Maybe the developers can take this and figure out what is missing with the new version of zen cart.
http://www.atmospherebooks.com/test/ML_ZC1_3_8_EXTENDED_BOOK_TYPE_V_4_LANGS_ISS2.zip

30 May 2012, 8:29 AM
#640
raunharman avatar

raunharman

Zen Follower

Join Date:
Dec 2005
Posts:
165
Plugin Contributions:
0

Re: Product Type Book (by moku)

I am getting the following error in the backend, when i click on description:
1054 Unknown column 'pe.size' in 'field list'
in:
[select pe.book_color_id, pe.book_condition_id, pe.subtitle, pe.pub_date, pe.size, pe.pages, pe.misc_1, pe.misc_2, pe.misc_bool_1, pe.misc_bool_2, pd.products_name, pd.products_description, pd.products_url, p.products_id, p.products_quantity, p.products_model, p.products_image, p.products_price, p.products_virtual, p.products_weight, p.products_date_added, p.products_last_modified, date_format(p.products_date_available, '%Y-%m-%d') as products_date_available, p.products_status, p.products_tax_class_id, p.manufacturers_id, p.products_quantity_order_min, p.products_quantity_order_units, p.products_priced_by_attribute, p.product_is_free, p.product_is_call, p.products_quantity_mixed, p.product_is_always_free_shipping, p.products_qty_box_status, p.products_quantity_order_max, p.products_sort_order, p.products_discount_type, p.products_discount_type_from, p.products_price_sorter, p.master_categories_id from products p, products_description pd, product_book_extra pe where p.products_id = '162' and p.products_id = pd.products_id and p.products_id = pe.products_id and pd.language_id = '1']
If you were entering information, press the BACK button in your browser and re-check the information you had entered to be sure you left no blank fields.

What could be the solution.
zen cart version is 1.3.8