[Skip to main content](#vessel-content)

#   Split Up Custom Items in default.php

##

- **[LenaK](/forum/user/6546-lenak "View LenaK's Profile")**
- [![LenaK's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/6546-lenak "View LenaK's Profile") Topic Author
- [ Offline](/forum/user/6546-lenak)

Less More

- Posts: 20
- Thank you received: 0
-
-

13 years 5 months ago [\#108394](#108394) by [LenaK](/forum/user/6546-lenak "View LenaK's Profile")  *[Split Up Custom Items in default.php](/forum/4-how-to/83518-split-up-custom-items-in-default-php#108394 "Hi, I've spent a couple days on this now and all I can do is duplicate the entire block of custom items with as little as 2 lines of code my default.php Product Page.  I want to move only one specific field to the right part of the default.php. Although I did find some discussion about displaying custom items, there is not enough detail to get the right syntax for just the one row.  My custom field name is &quot;includemyreturnaddress&quot;, it's id is 63 and it's a yes or no, with a &quot;no&quot; default. It might be just the way I am constructing the span id or the echo ... but i'm getting bupkas.  an example would be most appreciated and I'm sure I'll be able to apply the same method to the other fields as I don't want this field to repeat in the main part ...  Thanks in advance")* was created by *[LenaK](/forum/user/6546-lenak "View LenaK's Profile")*

Hi,
I've spent a couple days on this now and all I can do is duplicate the entire block of custom items with as little as 2 lines of code my default.php Product Page.

I want to move only one specific field to the right part of the default.php. Although I did find some discussion about displaying custom items, there is not enough detail to get the right syntax for just the one row.

My custom field name is "includemyreturnaddress", it's id is 63 and it's a yes or no, with a "no" default. It might be just the way I am constructing the span id or the echo ... but i'm getting bupkas.

an example would be most appreciated and I'm sure I'll be able to apply the same method to the other fields as I don't want this field to repeat in the main part ...

Thanks in advance

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzgzNTE4LXNwbGl0LXVwLWN1c3RvbS1pdGVtcy1pbi1kZWZhdWx0LXBocD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Xavier](/forum/user/4105-xavier "View Xavier's Profile")**
- [![Xavier's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar4105.png)](/forum/user/4105-xavier "View Xavier's Profile")
- [ Offline](/forum/user/4105-xavier)

Less More

- Posts: 13201
- Thank you received: 2322
-
-
-
- [](http://www.kidiweb.fr)
-

13 years 5 months ago [\#108411](#108411) by [Xavier](/forum/user/4105-xavier "View Xavier's Profile")  Replied by *[Xavier](/forum/user/4105-xavier "View Xavier's Profile")* on topic *[Split Up Custom Items in default.php](/forum/4-how-to/83518-split-up-custom-items-in-default-php#108411 "Hi, I've spent a couple days on this now and all I can do is duplicate the entire block of custom items with as little as 2 lines of code my default.php Product Page.  I want to move only one specific field to the right part of the default.php. Although I did find some discussion about displaying custom items, there is not enough detail to get the right syntax for just the one row.  My custom field name is &quot;includemyreturnaddress&quot;, it's id is 63 and it's a yes or no, with a &quot;no&quot; default. It might be just the way I am constructing the span id or the echo ... but i'm getting bupkas.  an example would be most appreciated and I'm sure I'll be able to apply the same method to the other fields as I don't want this field to repeat in the main part ...  Thanks in advance")*

Hi,

You can unpublish the custom field in the frontend, then edit the view displaying the product, generally "product / show_default" and add a code like:
Code:

&lt;input id="includemyreturnaddress_yes" type="radio" onclick="hikashopToggleFields(this.value,'includemyreturnaddress','item',0);" value="yes" name="data[item][includemyreturnaddress]"&gt;&lt;/input&gt; &lt;label for="includemyreturnaddress_yes"&gt;yes&lt;/label&gt; &lt;input id="includemyreturnaddress_no" type="radio" onclick="hikashopToggleFields(this.value,'includemyreturnaddress','item',0);" value="no" name="data[item][includemyreturnaddress]"&gt;&lt;/input&gt; &lt;label for="includemyreturnaddress_no"&gt;no&lt;/label&gt;

The following user(s) said Thank You: [LenaK](/forum/user/6546-lenak "View LenaK's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzgzNTE4LXNwbGl0LXVwLWN1c3RvbS1pdGVtcy1pbi1kZWZhdWx0LXBocD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[LenaK](/forum/user/6546-lenak "View LenaK's Profile")**
- [![LenaK's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/6546-lenak "View LenaK's Profile") Topic Author
- [ Offline](/forum/user/6546-lenak)

Less More

- Posts: 20
- Thank you received: 0
-
-

13 years 5 months ago [\#108510](#108510) by [LenaK](/forum/user/6546-lenak "View LenaK's Profile")  Replied by *[LenaK](/forum/user/6546-lenak "View LenaK's Profile")* on topic *[Split Up Custom Items in default.php](/forum/4-how-to/83518-split-up-custom-items-in-default-php#108510 "Hi, I've spent a couple days on this now and all I can do is duplicate the entire block of custom items with as little as 2 lines of code my default.php Product Page.  I want to move only one specific field to the right part of the default.php. Although I did find some discussion about displaying custom items, there is not enough detail to get the right syntax for just the one row.  My custom field name is &quot;includemyreturnaddress&quot;, it's id is 63 and it's a yes or no, with a &quot;no&quot; default. It might be just the way I am constructing the span id or the echo ... but i'm getting bupkas.  an example would be most appreciated and I'm sure I'll be able to apply the same method to the other fields as I don't want this field to repeat in the main part ...  Thanks in advance")*

Oh Thank You !
I cannot express a greater gratitude.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzgzNTE4LXNwbGl0LXVwLWN1c3RvbS1pdGVtcy1pbi1kZWZhdWx0LXBocD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[LenaK](/forum/user/6546-lenak "View LenaK's Profile")**
- [![LenaK's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/6546-lenak "View LenaK's Profile") Topic Author
- [ Offline](/forum/user/6546-lenak)

Less More

- Posts: 20
- Thank you received: 0
-
-

13 years 5 months ago [\#108965](#108965) by [LenaK](/forum/user/6546-lenak "View LenaK's Profile")  Replied by *[LenaK](/forum/user/6546-lenak "View LenaK's Profile")* on topic *[Split Up Custom Items in default.php](/forum/4-how-to/83518-split-up-custom-items-in-default-php#108965 "Hi, I've spent a couple days on this now and all I can do is duplicate the entire block of custom items with as little as 2 lines of code my default.php Product Page.  I want to move only one specific field to the right part of the default.php. Although I did find some discussion about displaying custom items, there is not enough detail to get the right syntax for just the one row.  My custom field name is &quot;includemyreturnaddress&quot;, it's id is 63 and it's a yes or no, with a &quot;no&quot; default. It might be just the way I am constructing the span id or the echo ... but i'm getting bupkas.  an example would be most appreciated and I'm sure I'll be able to apply the same method to the other fields as I don't want this field to repeat in the main part ...  Thanks in advance")*

This works well for displaying the custom items before they get added to cart. My trouble is that the custom items don't get added to the cart view in step one. I've tried to make modifications to the checkout / custom_fields.php file so that the data entered is displayed in the cart, but to no avail. Since all published custom fields display no problem i tried changing the custom_fields.php file to include the unpublished fields, but that doesn't display these custom fields in the checkout or my syntax had no errors.

I also don't seem to get any validation happening either for "required" content, so I'm wondering if i have to use form tags in my code. In that's the case, there doesn't appear to be a form for the checkout in my views tab and i don't know what form i would be posting.

Sure would appreciate some hints. Thank you.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzgzNTE4LXNwbGl0LXVwLWN1c3RvbS1pdGVtcy1pbi1kZWZhdWx0LXBocD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Xavier](/forum/user/4105-xavier "View Xavier's Profile")**
- [![Xavier's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar4105.png)](/forum/user/4105-xavier "View Xavier's Profile")
- [ Offline](/forum/user/4105-xavier)

Less More

- Posts: 13201
- Thank you received: 2322
-
-
-
- [](http://www.kidiweb.fr)
-

13 years 5 months ago [\#109029](#109029) by [Xavier](/forum/user/4105-xavier "View Xavier's Profile")  Replied by *[Xavier](/forum/user/4105-xavier "View Xavier's Profile")* on topic *[Split Up Custom Items in default.php](/forum/4-how-to/83518-split-up-custom-items-in-default-php#109029 "Hi, I've spent a couple days on this now and all I can do is duplicate the entire block of custom items with as little as 2 lines of code my default.php Product Page.  I want to move only one specific field to the right part of the default.php. Although I did find some discussion about displaying custom items, there is not enough detail to get the right syntax for just the one row.  My custom field name is &quot;includemyreturnaddress&quot;, it's id is 63 and it's a yes or no, with a &quot;no&quot; default. It might be just the way I am constructing the span id or the echo ... but i'm getting bupkas.  an example would be most appreciated and I'm sure I'll be able to apply the same method to the other fields as I don't want this field to repeat in the main part ...  Thanks in advance")*

Hi,

Sorry, you have to let it published, add the code in the view and add some css to hide the default custom field.
You can use the css property: Code:

.hikashop_product_custom_item_value_64{display:none;}

Where 64 has to be replaced with the id of the custom field.

The following user(s) said Thank You: [LenaK](/forum/user/6546-lenak "View LenaK's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzgzNTE4LXNwbGl0LXVwLWN1c3RvbS1pdGVtcy1pbi1kZWZhdWx0LXBocD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[LenaK](/forum/user/6546-lenak "View LenaK's Profile")**
- [![LenaK's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/6546-lenak "View LenaK's Profile") Topic Author
- [ Offline](/forum/user/6546-lenak)

Less More

- Posts: 20
- Thank you received: 0
-
-

13 years 5 months ago [\#109151](#109151) by [LenaK](/forum/user/6546-lenak "View LenaK's Profile")  Replied by *[LenaK](/forum/user/6546-lenak "View LenaK's Profile")* on topic *[Split Up Custom Items in default.php](/forum/4-how-to/83518-split-up-custom-items-in-default-php#109151 "Hi, I've spent a couple days on this now and all I can do is duplicate the entire block of custom items with as little as 2 lines of code my default.php Product Page.  I want to move only one specific field to the right part of the default.php. Although I did find some discussion about displaying custom items, there is not enough detail to get the right syntax for just the one row.  My custom field name is &quot;includemyreturnaddress&quot;, it's id is 63 and it's a yes or no, with a &quot;no&quot; default. It might be just the way I am constructing the span id or the echo ... but i'm getting bupkas.  an example would be most appreciated and I'm sure I'll be able to apply the same method to the other fields as I don't want this field to repeat in the main part ...  Thanks in advance")*

Ok, that works better for some fields. It started off with just one field and has expanded to the whole set.

If a textarea is required, my cart goes through a continuous loop and doesn't recognize the data that is entered by the user using the following code in my default.php. Hopefully you can spot the problem.

Additionally with textareas, I thought I might get the characters remaining to display using the following code, however that didn't pan out for me either, but I was just guessing based on the "onclick" syntax.

&lt;textarea name="data[item][recipient]" id="recipient" rows="4" cols="45" onclick="hikashopToggleFields(this.value,'recipient','item',0);" onblur="hikashopTextCounter(this.value,'recipient_count','item',0);" onkeyup="hikashopTextCounter(this.value,'recipient_count','item',0);" &gt;&lt;/textarea&gt;

If i'm using a date field, the calendar does not become active whether i use the following code or if i change the type to "date" or "item" instead of text. It looks nice.

&lt;label&gt;Mail Later&lt;/label&gt;
&lt;input id="maillater" type="text" onchange="maillater_checkDate(1);" value="&lt;?php echo date('Y-m-d'); ?&gt;" name="data[item][maillater]" &gt;
&lt;img id="maillater_img" class="calendar" alt="Calendar" src="/media/system/images/calendar.png"&gt;

I would appreciate your suggestions. Thank you.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzgzNTE4LXNwbGl0LXVwLWN1c3RvbS1pdGVtcy1pbi1kZWZhdWx0LXBocD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86560
- Thank you received: 14307
-
-

13 years 5 months ago [\#109281](#109281) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Split Up Custom Items in default.php](/forum/4-how-to/83518-split-up-custom-items-in-default-php#109281 "Hi, I've spent a couple days on this now and all I can do is duplicate the entire block of custom items with as little as 2 lines of code my default.php Product Page.  I want to move only one specific field to the right part of the default.php. Although I did find some discussion about displaying custom items, there is not enough detail to get the right syntax for just the one row.  My custom field name is &quot;includemyreturnaddress&quot;, it's id is 63 and it's a yes or no, with a &quot;no&quot; default. It might be just the way I am constructing the span id or the echo ... but i'm getting bupkas.  an example would be most appreciated and I'm sure I'll be able to apply the same method to the other fields as I don't want this field to repeat in the main part ...  Thanks in advance")*

What you want to do won't work with the method explained by Xavier.
The date field as well as the textarea field require js code that is only added when you call the display function of the field class with the correct parameters.
If you add the HTML on your end, you won't have the JS linked to it and thus it won't work.
The problem is the same for the check for required fields as the system won't find your HTML field and will deny the submission.

What you will need to do is to use the PHP code to generate your fields manually and completely remove the normal call to the custom fields display block in your default.php file.

Here is an example of code for your radio button: Code:

&lt;?php $oneExtraField =&amp; $this-&gt;itemFields['includemyreturnaddress']; $itemData = JRequest :: getString('item_data_includemyreturnaddress', $this-&gt;element-&gt;includemyreturnaddress); $onWhat='onchange'; if($oneExtraField-&gt;field_type=='radio') $onWhat='onclick'; $oneExtraField-&gt;product_id = $this-&gt;element-&gt;product_id; echo $this-&gt;fieldsClass-&gt;display($oneExtraField,$itemData,'data[item][includemyreturnaddress]',false,' '.$onWhat.'="hikashopToggleFields(this.value,\'includemyreturnaddress\',\'item\',0);"'); ?&gt;

The following user(s) said Thank You: [LenaK](/forum/user/6546-lenak "View LenaK's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzgzNTE4LXNwbGl0LXVwLWN1c3RvbS1pdGVtcy1pbi1kZWZhdWx0LXBocD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[LenaK](/forum/user/6546-lenak "View LenaK's Profile")**
- [![LenaK's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/6546-lenak "View LenaK's Profile") Topic Author
- [ Offline](/forum/user/6546-lenak)

Less More

- Posts: 20
- Thank you received: 0
-
-

13 years 5 months ago [\#109283](#109283) by [LenaK](/forum/user/6546-lenak "View LenaK's Profile")  Replied by *[LenaK](/forum/user/6546-lenak "View LenaK's Profile")* on topic *[Split Up Custom Items in default.php](/forum/4-how-to/83518-split-up-custom-items-in-default-php#109283 "Hi, I've spent a couple days on this now and all I can do is duplicate the entire block of custom items with as little as 2 lines of code my default.php Product Page.  I want to move only one specific field to the right part of the default.php. Although I did find some discussion about displaying custom items, there is not enough detail to get the right syntax for just the one row.  My custom field name is &quot;includemyreturnaddress&quot;, it's id is 63 and it's a yes or no, with a &quot;no&quot; default. It might be just the way I am constructing the span id or the echo ... but i'm getting bupkas.  an example would be most appreciated and I'm sure I'll be able to apply the same method to the other fields as I don't want this field to repeat in the main part ...  Thanks in advance")*

You all rock.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzgzNTE4LXNwbGl0LXVwLWN1c3RvbS1pdGVtcy1pbi1kZWZhdWx0LXBocD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[LenaK](/forum/user/6546-lenak "View LenaK's Profile")**
- [![LenaK's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/6546-lenak "View LenaK's Profile") Topic Author
- [ Offline](/forum/user/6546-lenak)

Less More

- Posts: 20
- Thank you received: 0
-
-

13 years 5 months ago [\#109353](#109353) by [LenaK](/forum/user/6546-lenak "View LenaK's Profile")  Replied by *[LenaK](/forum/user/6546-lenak "View LenaK's Profile")* on topic *[Split Up Custom Items in default.php](/forum/4-how-to/83518-split-up-custom-items-in-default-php#109353 "Hi, I've spent a couple days on this now and all I can do is duplicate the entire block of custom items with as little as 2 lines of code my default.php Product Page.  I want to move only one specific field to the right part of the default.php. Although I did find some discussion about displaying custom items, there is not enough detail to get the right syntax for just the one row.  My custom field name is &quot;includemyreturnaddress&quot;, it's id is 63 and it's a yes or no, with a &quot;no&quot; default. It might be just the way I am constructing the span id or the echo ... but i'm getting bupkas.  an example would be most appreciated and I'm sure I'll be able to apply the same method to the other fields as I don't want this field to repeat in the main part ...  Thanks in advance")*

Oh man! I have all my custom item fields displaying EXACTLY as I want them now. The final code that worked for me was this:

&lt;?php
$oneExtraField =&amp; $this-&gt;itemFields;
$itemData = JRequest :: getString('item_data_includemyreturnaddress', $this-&gt;element-&gt;includemyreturnaddress);
?&gt;
&lt;td class="key"&gt;
&lt;span id="hikashop_product_custom_item_name_includemyreturnaddress" class="hikashop_product_custom_item_name"&gt;
&lt;?php echo $this-&gt;fieldsClass-&gt;getFieldName($oneExtraField);?&gt;
&lt;/span&gt;
&lt;/td&gt;
&lt;td&gt;
&lt;span id="hikashop_product_custom_item_value_includemyreturnaddress" class="hikashop_product_custom_item_value"&gt;
&lt;?php
$onWhat='onchange';
if($oneExtraField-&gt;field_type=='radio')
$onWhat='onclick';
$oneExtraField-&gt;product_id = $this-&gt;element-&gt;product_id;
echo $this-&gt;fieldsClass-&gt;display($oneExtraField,$itemData,'data[item]',false,' '.$onWhat.'="hikashopToggleFields(this.value,\''.$fieldName.'\',\'item\',0);"');
?&gt;&lt;/span&gt;
&lt;/td&gt;

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzgzNTE4LXNwbGl0LXVwLWN1c3RvbS1pdGVtcy1pbi1kZWZhdWx0LXBocD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.068 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)
