Page 1 of 2 12 LastLast
Results 1 to 10 of 12
  1. #1
    Join Date
    Jan 2007
    Posts
    375
    Plugin Contributions
    3

    Idea or Suggestion How to make the Long Title limit char. long?

    Hi all,

    I am using 1.3.7 with a bought template from online ...

    We all know the main home page have the "New Products of August"

    It have the product title ....

    The problems here, my products general long title, Over 50 to 100 words ...

    I want to make like that .. for example ...

    Halo 3 ODST Only on XBOX 360

    I want it reformat like limit word to like that

    Halo 3 ODST Only ...

    Have the ... at the end .. and limit char word ...


    I am not programming ... but I finded the code that using on my template

    $products_name = '<a href="' . zen_href_link(zen_get_info_page($new_products->fields['products_id']), 'cPath=' . $productsInCategory[$new_products->fields['products_id']] . '&products_id=' . $new_products->fields['products_id']) . '">' . $new_products->fields['products_name'] . '</a>';


    How to reformat above code to make what I want to be?

    Thank you very much and you time to help me.

  2. #2
    Join Date
    Apr 2009
    Posts
    2,134
    Plugin Contributions
    3

    Default Re: How to make the Long Title limit char. long?

    You may be looking in the wrong place. Or you are if I understand correctly and you are trying to change the new products box in the center column.

    You need to find new_products.php.

    First make an override version of it if one does not exist already. So copy this file:

    includes/modules/new_products.php

    to this postition ( create folders if you need to )

    includes/modules/yourtemplate/new_products.php.

    Then you are going to edit this new file. Find the bit that reads:

    Code:
      while (!$new_products->EOF) {
        $products_price = zen_get_products_display_price($new_products->fields['products_id']);
        if (!isset($productsInCategory[$new_products->fields['products_id']])) $productsInCategory[$new_products->fields['products_id']] = zen_get_generated_category_path_rev($new_products->fields['master_categories_id']);
    
        $list_box_contents[$row][$col] = array('params' => 'class="centerBoxContentsNew centeredContent back"' . ' ' . 'style="width:' . $col_width . '%;"',
        'text' => (($new_products->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0) ? '' : '<a href="' . zen_href_link(zen_get_info_page($new_products->fields['products_id']), 'cPath=' . $productsInCategory[$new_products->fields['products_id']] . '&products_id=' . $new_products->fields['products_id']) . '">' . zen_image(DIR_WS_IMAGES . $new_products->fields['products_image'], $new_products->fields['products_name'], IMAGE_PRODUCT_NEW_WIDTH, IMAGE_PRODUCT_NEW_HEIGHT) . '</a><br />') . '<a href="' . zen_href_link(zen_get_info_page($new_products->fields['products_id']), 'cPath=' . $productsInCategory[$new_products->fields['products_id']] . '&products_id=' . $new_products->fields['products_id']) . '">' . $new_products->fields['products_name'] . '</a><br />' . $products_price);
    Then you are going to add two chunks of code (both in red):

    Code:
      while (!$new_products->EOF) {
    //niccol
    $niccol=$new_products->fields['products_name'];
    $niccol_array=explode(' ',$niccol);
    if(count($niccol_array)>=4 ? $niccol_end='...' : $niccol_end='');
    $niccol_new=$niccol_array[0].' '.$niccol_array[1].' '.$niccol_array[2].$niccol_end;
    //niccol end
        $products_price = zen_get_products_display_price($new_products->fields['products_id']);
        if (!isset($productsInCategory[$new_products->fields['products_id']])) $productsInCategory[$new_products->fields['products_id']] = zen_get_generated_category_path_rev($new_products->fields['master_categories_id']);
    
        $list_box_contents[$row][$col] = array('params' => 'class="centerBoxContentsNew centeredContent back"' . ' ' . 'style="width:' . $col_width . '%;"',
        'text' => (($new_products->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0) ? '' : '<a href="' . zen_href_link(zen_get_info_page($new_products->fields['products_id']), 'cPath=' . $productsInCategory[$new_products->fields['products_id']] . '&products_id=' . $new_products->fields['products_id']) . '">' . zen_image(DIR_WS_IMAGES . $new_products->fields['products_image'], $new_products->fields['products_name'], IMAGE_PRODUCT_NEW_WIDTH, IMAGE_PRODUCT_NEW_HEIGHT) . '</a><br />') . '<a href="' . zen_href_link(zen_get_info_page($new_products->fields['products_id']), 'cPath=' . $productsInCategory[$new_products->fields['products_id']] . '&products_id=' . $new_products->fields['products_id']) . '">' . /*$new_products->fields['products_name'] .*//*niccol start*/$niccol_new./*niccol end*/ '</a><br />' . $products_price);
    Probably it is easy to copy and paste from the forum into your file.

    This will only display the first three words of the title. If you want to change that number it is easy to do in the first chunk of code.

  3. #3
    Join Date
    Jan 2007
    Posts
    375
    Plugin Contributions
    3

    Default Re: How to make the Long Title limit char. long?

    Nick,

    Thank you. yes the file are what I want to change ...

    But I am using override already, and the coding I post there is the template that using the override's coding ....

    The template author make this code.

    I just know that if I need control the output format...

    Much change this coding....

    Since I have other web site that have other template installed ... and I changed the result like what I want by using PHP's

    substr, strlen, strip_tags

    I give you the coding example for your refernece, that is I want to change the original template author coding like that one using substr, strlen, strip_tags but I an out of lucky ...

    The coding is there:

    $product_info_str .= (strlen($product_info->fields['products_description']) > 100) ? substr(strip_tags($product_info->fields['products_description']), 0, 100) . '&hellip;' : strip_tags($product_info->fields['products_description']);


  4. #4
    Join Date
    Apr 2009
    Posts
    2,134
    Plugin Contributions
    3

    Default Re: How to make the Long Title limit char. long?

    OK well thats fine.

    Use the code that I posted wherever you want. The first bit of the code does the work:

    Code:
    $niccol=$new_products->fields['products_name'];
    $niccol_array=explode(' ',$niccol);
    if(count($niccol_array)>=4 ? $niccol_end='...' : $niccol_end='');
    $niccol_new=$niccol_array[0].' '.$niccol_array[1].' '.$niccol_array[2].$niccol_end;
    Line 1: Set variable $niccol to be the same as the products name

    Line 2: turn the description into an array of individual words.

    Line 3. If the array is smaller than 4 words do not use '...'

    Line 4. Build a new variable that is the first three words of $niccol

    These four lines act on any string that you set in the first line. So, what ever the string is the variable $niccol_new will be the first three words.

    You can use it wherever you want in the file.

    This is the code you are replacing?
    Code:
    $products_name = '<a href="' . zen_href_link(zen_get_info_page($new_products->fields['products_id']), 'cPath=' . $productsInCategory[$new_products->fields['products_id']] . '&products_id=' . $new_products->fields['products_id']) . '">' . $new_products->fields['products_name'] . '</a>';
    |If that is right then this is what you want:

    Code:
    $products_name = '<a href="' . zen_href_link(zen_get_info_page($new_products->fields['products_id']), 'cPath=' . $productsInCategory[$new_products->fields['products_id']] . '&products_id=' . $new_products->fields['products_id']) . '">' . $new_products->fields['products_name'] . '</a>';
    $niccol=$new_products->fields['products_name']
    $niccol_array=explode(' ',$niccol);
    if(count($niccol_array)>=4 ? $niccol_end='...' : $niccol_end='');
    $niccol_new=$niccol_array[0].' '.$niccol_array[1].' '.$niccol_array[2].$niccol_end;
    $products_name_niccol= '<a href="' . zen_href_link(zen_get_info_page($new_products->fields['products_id']), 'cPath=' . $productsInCategory[$new_products->fields['products_id']] . '&products_id=' . $new_products->fields['products_id']) . '">' . $niccol_end. '</a>';
    $products_name=$products_name_niccol;
    I have not been able to test this code so check it before using it.

  5. #5
    Join Date
    Jan 2007
    Posts
    375
    Plugin Contributions
    3

    Default Re: How to make the Long Title limit char. long?

    Nick,

    It not work ...

    Or do I need give you my template for install on your shop to help for testing?

    I can give my template that using for you.

    Thank you very much.

  6. #6
    Join Date
    Apr 2009
    Posts
    2,134
    Plugin Contributions
    3

    Default Re: How to make the Long Title limit char. long?

    post your version of the template file (includes/modules/yourtemplate/new_products.php) as an attachment to the post. You will need to zip it first to attach it.

    Also post a URL please.

  7. #7
    Join Date
    Jan 2007
    Posts
    375
    Plugin Contributions
    3

    Default Re: How to make the Long Title limit char. long?

    Hi Niccol,

    Attachment file give to you....

    If you need the full template, just ask me, I can PM you the download URL.

    1000 x Thank you of your time and help me.

    Best Regards,
    Jimmy Chan
    Attached Files Attached Files

  8. #8
    Join Date
    Jan 2007
    Posts
    375
    Plugin Contributions
    3

    Default Re: How to make the Long Title limit char. long?

    Coding on line 85 and 196

    Please note that 196 is the final output ..... base on my poor knowledge ....

    Just know that 196 is using line 85 to format the output ...

  9. #9
    Join Date
    Apr 2009
    Posts
    2,134
    Plugin Contributions
    3

    Default Re: How to make the Long Title limit char. long?

    Thanks. I am in meetings all day today so it will be a while until I get a chance to really look at it.

  10. #10
    Join Date
    Jan 2007
    Posts
    375
    Plugin Contributions
    3

    Default Re: How to make the Long Title limit char. long?

    Niccol,

    Never mind, I am very thank you of your kindly help.

    Wish you all the best and have a nice day.

    Jimmy Chan

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. How long on the average should it take to upgrade?
    By richk58 in forum Upgrading from 1.3.x to 1.3.9
    Replies: 3
    Last Post: 24 Feb 2011, 11:40 PM
  2. How long to update the inventory after checkout?
    By DBNY in forum General Questions
    Replies: 1
    Last Post: 25 May 2010, 12:47 PM
  3. It's been a long, long time....
    By friends1976 in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 14 Mar 2010, 09:31 AM
  4. Long (very long!) product names break Tell A Friend page + FIX
    By Ryk in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 24 Feb 2007, 02:10 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg