Zen Cart Logo
Forums / Setting Up Categories, Products, Attributes / Make input field on collectinfo also display the field text as hyperlink

Make input field on collectinfo also display the field text as hyperlink

Views: 871

Results 1 to 4 of 4
14 Dec 2012, 8:32 PM
#1
jpietrowiak avatar

jpietrowiak

Zen Follower

Join Date:
May 2009
Posts:
122
Plugin Contributions:
0

Make input field on collectinfo also display the field text as hyperlink

I am trying to figure out how to take field data thats in an input field and make a link out of it right next to it. So in otherwords when you click to edit a product on that page. There would be data in editable field. In that field I would enter "example.com". I would then save the page. Now when I reopen the page the input field would still be available, however I would like right next to it to display in another <td>http://(inputfield data) </td> . I tried echoing the data out but nothing shows up.

Any one have any ideas on how to make this work?

14 Dec 2012, 8:44 PM
#2
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Make input field on collectinfo also display the field text as hyperlink

Is this an existing editable field you are talking about, or a new one you want to add? Assuming you have the database handling set up, the first time you go to that edit page there would be nothing in the "link display" area, right? Then when you came back, you would want the previously-entered content to display there. This would be handled by retrieving the db field when building the page, and inserting its value into the "link display" output code. How much do you know about db interaction? And why do you want to display the content as an actual link next to the input field? More commonly, when there is existing info for a field, I think you would want to display it as prefilled text in the input, ready to be amended if necessary or used as is.

More detail on exactly what code you have already tried would probably help clarify your intent and give a start on suggesting improvements.

14 Dec 2012, 11:24 PM
#3
jpietrowiak avatar

jpietrowiak

Zen Follower

Join Date:
May 2009
Posts:
122
Plugin Contributions:
0

Re: Make input field on collectinfo also display the field text as hyperlink

Hi gjh42,
Thanks for the reply! Sorry I don't know hardly anything about database interaction other then trying to copy snippets of code from pages that exist to make something work the same. I'm technically inclined just don't understand what the functions actually completely do.There are two ways or options that I think would be ok. The reason I want to do this is for an internal link that someone can just click to go to vendor to reorder stock easily. This is Zen 1.5.1

1st option- Use zencarts current field then I would remove it from public display on product page.

Code from collect_info.php page that I think would be edited or have something right after
<td class="main"><?php if ($i == 0) echo TEXT_PRODUCTS_URL . '<br /><small>' . TEXT_PRODUCTS_URL_WITHOUT_HTTP . '</small>'; ?></td>
Then add something like this after <td> <?php echo http:// TEXT_PRODUCTS_URL_WITHOUT_HTTP ?> </td>

2nd option- Or I have figured out how to create extra internal only fields (not public), So I would need a way to leave the editable field and the get current data in this editable field as well as display as editable link next to it.
<td class="main"><?php echo TEXT_PRODUCTS_VENDOR_LINK; ?></td>
<td class="main"><?php echo zen_draw_separator('pixel_trans.gif', '4', '15') . ' ' . zen_draw_input_field('products_vendor_url', $pInfo->products_vendor_url, ''); ?></td>

Then add something like this after <td> <?php echo http:// products_vendor_url ?> </td>

Hope this makes more sense.

Petro

15 Dec 2012, 4:06 AM
#4
jpietrowiak avatar

jpietrowiak

Zen Follower

Join Date:
May 2009
Posts:
122
Plugin Contributions:
0

Re: Make input field on collectinfo also display the field text as hyperlink

With some trial and error 2 hours later I was able to get it to work with the following code for a field I added in the admin/includes/modules/product/collect_info.php . Not sure if this is the best way but it seems to work, hope this helps someone that may be trying to do the same thing.

<td class="main"><?php echo TEXT_PRODUCTS_VENDOR_WEBSITE; ?></td>

<td class="main"><?php echo zen_draw_separator('pixel_trans.gif', '4', '15') . ' ' . zen_draw_input_field('products_websitejp', $pInfo->products_websitejp, ''); ?> <!-- JP Added to display link --> <br>    <?php echo "<a target=frame2 href='" . 'http://' . $pInfo->products_websitejp . $row['FirstName'] . "'>Link to Website</a>"; ?> </td>