chrometweaks.org

What would be a good iPage web host for a freelance graphic designer?

Click Here To View All Answers...


Got a question, hope someone can answer... What would be a good iPage web host for a freelance graphic designer? Hoping for any answer. Second question of mine... Hi Guys,.

I have some rather large product names in my store and I need to splice the product name just like in the star products contrib..

I have tried applying the same principles in the product_listing_col.php file but all it does is lose my products..

Will you please take a look at the code below and let me know where you think I am going wrong..

$info_box_contents = array();.

   $info_box_contents[0] = array('params' => 'class="productListing-odd"');.

   $info_box_contents[0][] = array('params' => 'class="productListing-data"',.

                                  'text' => TEXT_NO_PRODUCTS);.

    $info_box_contents_output = array_slice($info_box_contents, sizeof($info_box_contents)-1);.

   new contentBox($info_box_contents_output);.

Thanks.

Mark..

Comments (68)

I would like to know the answer too. Anyone here know what is the answer to your question. I'll do some research and get back to you if I discover an useful answer. You should email the people at iPage as they probably could assist you..

Comment #1

Hi Jack,.

This is what the product name looks like at the mo.

And this is what I want it to look like.

If you take a look at my site, on the main page you will see some products with the titles spliced..

Basically I just want the products listing to be the same..

Thanks.

Mark..

Comment #2

I could be wrong here, but I don't think array_slice is what you want to use. Let's assume you have an array filled with your products like this:.

$products = array("Nokia MA-8610C USB_1", "Nokia MA-8610C USB_2", "Nokia MA-8610C USB_3");.

Using array_splice, you can split the array to have it show only Nokia MA-8610C USB 2, for example. But you want to split the individual phase. I think what you might need instead is to use explode. Something like:.

$str = explode(" ", $product[0]);  .

This would give you:.

Then you can add the strings together to get the desired length:.

If (strlen($str[0]) + strlen($str[1]) < MAX_LENGTH) {.

$line1 = $str[0]' '$str[1];.

$line2 = $str[2];.

} else {.

$line1 = $str[0];.

$line2 = $str[1]' '$str[2];.

}.

This is just my thoughts. You will need to make it more dynamic since it is doubtful that all products will have the same number of elements but I think you see the concept..

Jack..

Comment #3

You might want to look at the following function in general.php.

Tep_break_string()..

Comment #4

Mark,.

I presume that this is the code you mean.

////.

// Break a word in a string if it is longer than a specified length ($len).

 function tep_break_string($string, $len, $break_char = '-') {.

   $l = 0;.

   $output = '';.

   for ($i=0, $n=strlen($string); $i<$n; $i++) {.

     $char = substr($string, $i, 1);.

     if ($char != ' ') {.

       $l++;.

     } else {.

       $l = 0;.

     }.

     if ($l > $len) {.

       $l = 1;.

       $output .= $break_char;.

     }.

     $output .= $char;.

   }.

   return $output;.

 }.

Still not sure what to do though!.

Mark..

Comment #5

If you want to break a string after a certain length use something like this.

<?php.

 echo tep_break_string($mystring, 60, '<br>');.

?>.

That will insert a line break after the 60th charector so the text will wrap around to the next line...

Comment #6

Hi Guys,.

I have some rather large product names in my store and I need to splice the product name just like in the star products contrib..

I have tried applying the same principles in the product_listing_col.php file but all it does is lose my products..

Will you please take a look at the code below and let me know where you think I am going wrong..

$info_box_contents = array();.

   $info_box_contents[0] = array('params' => 'class="productListing-odd"');.

   $info_box_contents[0][] = array('params' => 'class="productListing-data"',.

                                  'text' => TEXT_NO_PRODUCTS);.

    $info_box_contents_output = array_slice($info_box_contents, sizeof($info_box_contents)-1);.

   new contentBox($info_box_contents_output);.

Thanks.

Mark..

Comment #7

I am not familar with the Star Products contribution so I don't know what you are trying to accomplish. Also, I haven't used the array_slice function but from my understanding, the second argument is the offset. You are telling it to go to the last item. If you give an exmple of your input and the desired output, I, or someone, would have a better chance of helping (if the above doesn't)..

Jack..

Comment #8


This question was taken from a support group/message board and re-posted here so others can learn from it.