Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

proper html formatting in infobox(); function call


zathrus

Recommended Posts

$info_box_contents[] .= '<tr><td class="infoBoxContents"><a href=http://somewhere.com/Topics/TGengine.cgi?ZType=' . $row[0] . '&ZID=' . $row[1] . '>' . $topic_type_row[0] . '</a> </td></tr>';

 

new infoBox($info_box_contents);

 

I'm just trying to use the existing infoBox function to list a few cgi links and I'm wondering what the proper formatting is for html/text mixed with variables, if there's anything specific for oscommerce functions in general.

 

Does OSCommerce have any full documentation on it's functions?

 

This is the output that's coming out at present.

<<

<<

<<

Whereas each row should be a cgi link.

 

Other usual formatting attempts have returned Tstring error's or other parse error's.

Link to comment
Share on other sites

just wondering, (blind question)

why wouldn't a function like this be programmed to take straight html and variables the same way as a php print or echo statement would?

Link to comment
Share on other sites

I couldn't find what I was looking for in that documentation, but thanks that'll come in handy.

 

basically, there just seems to be a problem with either a string concatenation or with my knowledge of how oscommerce and the infoBox function is supposed to be called and how links are supposed to be passed to it. I didn't really get anything when reading the infoBox source code either.

 

here's the section of code I'm puzzling over.

the formatting may look ugly here.. I've labeld different attempts at the concatenate statement that produce different results..

 

while($row = mysql_fetch_row($topic_result))

{

//row[0]=Topic_Type row[1]=Topic_ID

$test = $row[0];

 

$topic_types_query = "SELECT Name FROM `Topic_Types` WHERE Topic_Type = '$test' LIMIT 1";

$topic_type_result = mysql_query($topic_types_query);

$topic_type_row = mysql_fetch_row($topic_type_result);

 

attempt 1

//$info_box_contents[] .= '<tr><td><a href="http://somelink.com/Topics/somecgifile.cgi/?ZType=' . $row[0] . '&ZID=' . $row[1] . '">' . $topic_type_row[0] . '</a> </td></tr>';

 

attempt 1 produces the following output inside the box

<<

<<

<<

 

this is just an example I borrowed form one of oscommerces functions//<tr><td class="infoBoxContents"><a href="' . tep_href_link(FILENAME_PRODUCT_REVIEWS_WRITE, 'products_id=' . $HTTP_GET_VARS['products_id']) . '">' . tep_image(DIR_WS_IMAGES . 'box_write_review.gif', IMAGE_BUTTON_WRITE_REVIEW) . '</a></td>

 

 

attempt 2

//$info_box_contents[] .= '<tr><td><a href="http://somelink.com/Topics/somecgifile.cgi/?ZType='$row[0]'&ZID='$row[1]'">'$topic_type_row[0]'</a></td></tr>';

 

attempt 2 produces this error

Parse error: parse error, unexpected T_VARIABLE in /www/catalog/includes/boxes/file that is being included in the right column.php on line 57

 

 

attempt 3

$info_box_contents[] .= "<tr><td><a href=http://somelink.com/Topics/somecgifile.cgi/?ZType=$row[0]&ZID=$row[1]>$topic_type_row[0]</a></td></tr>";

}

attempt 3 produces the the same output as attempt 1

 

new infoBox($info_box_contents);

 

so the question is, am I wrong in how I'm concatenating the array, or in how I'm expecting the the infoBox function to handle direct html in a variable.

 

I did see a tep_href_something function but am not sure if that's the route I need to take.

 

Thanks for any advice

Link to comment
Share on other sites

Also, try building the http link outside of the function call in another variable.

-------------------------------------------------------------------------------------------------------------------------

NOTE: As of Oct 2006, I'm not as active in this forum as I used to be, but I still work with osC quite a bit.

If you have a question about any of my posts here, your best bet is to contact me though either Email or PM in my profile, and I'll be happy to help.

Link to comment
Share on other sites

Attemp 1 is definatly the way you have to do it. The other two ways will not work. Looking at it, nothing is jumping off the page at me. I'll tinker with it a bit, adn see if I can get it working.

-------------------------------------------------------------------------------------------------------------------------

NOTE: As of Oct 2006, I'm not as active in this forum as I used to be, but I still work with osC quite a bit.

If you have a question about any of my posts here, your best bet is to contact me though either Email or PM in my profile, and I'll be happy to help.

Link to comment
Share on other sites

$info_box_contents[] .= '<tr><td class="infoBoxContents"><a href=http://somewhere.com/Topics/TGengine.cgi?ZType=' . $row[0] . '&ZID=' . $row[1] . '>' . $topic_type_row[0] . '</a> </td></tr>';

 

from your first post should be

 

$info_box_contents[] .= '<tr><td class="infoBoxContents"><a href="http://somewhere.com/Topics/TGengine.cgi?ZType=' . $row[0] . '&ZID=' . $row[1] . '">' . $topic_type_row[0] . '</a> </td></tr>';

 

but this seems to be fixed in your attempt 1

-------------------------------------------------------------------------------------------------------------------------

NOTE: As of Oct 2006, I'm not as active in this forum as I used to be, but I still work with osC quite a bit.

If you have a question about any of my posts here, your best bet is to contact me though either Email or PM in my profile, and I'll be happy to help.

Link to comment
Share on other sites

yeah, and trying the same thing with the double quotes in attempt 3 produces an unexpected t-string error

 

I wonder if this is something really simple.

It always is, isn't it?

Link to comment
Share on other sites

Like I said, try building the link first, and then adding it to the infobox contents.

-------------------------------------------------------------------------------------------------------------------------

NOTE: As of Oct 2006, I'm not as active in this forum as I used to be, but I still work with osC quite a bit.

If you have a question about any of my posts here, your best bet is to contact me though either Email or PM in my profile, and I'll be happy to help.

Link to comment
Share on other sites

if I'm doing it right that doesn't seem to be working either

 

I think I'll take the easy solution and copy the table format from the oscommerce code instead of trying their api.

 

Probably save me a lot of headache.

Link to comment
Share on other sites

well, I got it working. Not as cleanly as I would like though.

 

it was to dowith the variables row[0] and row[1]

although in other cases using the same style of queries I've never had a problem,

 

in this case, trying to print row[0] produced, nothing, and trying to print row[1] produced a > sign ... odd, one should be a string, and one's an id number.

 

But, when I set the two array indexes = to a test variable, the statement worked as intended. Yet, there was another array in statement that showed up fine.

 

Not being experienced with php I find this really odd.

$info_box_contents[] .= "<tr><td><a href=http://somelink.com/Topics/somecgifile.cgi/?ZType=$row[0]&ZID=$row[1]>$topic_type_row[0]</a></td></tr>";

 

that's the broken one

the broken one didn't work regardless of whether I added array('text' => )

section

 

here's the working one

$info_box_contents[] = array('text' => "<tr><td><a href=http://somesite.com/Topics/somecgifile.cgi?ZType=$test&ZID=$test2>$topic_type_row[0]</a></td></tr>");

 

notice row[0] and row[1] are replaced, but the $topic_type_row[0] is same, yet that made the difference :?:

 

Thanks for you help Chris

I appreciated it.

 

Now it works just right.

Until next time 8)

 

Jonathan

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...