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

#   How to suppress blank address line 2

##

- **[mkj101us](/forum/user/9513-mkj101us "View mkj101us's Profile")**
- [![mkj101us's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar9513.jpeg)](/forum/user/9513-mkj101us "View mkj101us's Profile") Topic Author
- [ Offline](/forum/user/9513-mkj101us)

Less More

- Posts: 12
- Thank you received: 0
-
-

14 years 4 weeks ago [\#72471](#72471) by [mkj101us](/forum/user/9513-mkj101us "View mkj101us's Profile")  *[How to suppress blank address line 2](/forum/4-how-to/72471-how-to-suppress-blank-address-line-2#72471 "Hello,  I'm trying to modify address / address&#95;template.php to suppress {address&#95;street2} if it is blank. However, I cannot get access to the value of {address&#95;street2} to check its length.  I can tell I do not have the value of {address&#95;street2} by adding this to the template:    That will print the label, rather than the value:  Array ( &#91;0&#93; =&gt; { &#91;1&#93; =&gt; a &#91;2&#93; =&gt; d &#91;3&#93; =&gt; d &#91;4&#93; =&gt; r &#91;5&#93; =&gt; e &#91;6&#93; =&gt; s &#91;7&#93; =&gt; s &#91;8&#93; =&gt; &#95; &#91;9&#93; =&gt; s &#91;10&#93; =&gt; t &#91;11&#93; =&gt; r &#91;12&#93; =&gt; e &#91;13&#93; =&gt; e &#91;14&#93; =&gt; t &#91;15&#93; =&gt; 2 &#91;16&#93; =&gt; } )  But what I don't understand is why this does print the value of {address&#95;street2}:    Is there a way to check for the existence of a value in {address&#95;street2} and not print that line if there is nothing in it?  Thanks, -Mike")* was created by *[mkj101us](/forum/user/9513-mkj101us "View mkj101us's Profile")*

Hello,

I'm trying to modify address / address_template.php to suppress {address_street2} if it is blank. However, I cannot get access to the value of {address_street2} to check its length.

I can tell I do not have the value of {address_street2} by adding this to the template:

&lt;?php
$arr1 = str_split('{address_street2}');
print_r($arr1);
?&gt;

That will print the label, rather than the value:

Array
(
[0] =&gt; {
[1] =&gt; a
[2] =&gt; d
[3] =&gt; d
[4] =&gt; r
[5] =&gt; e
[6] =&gt; s
[7] =&gt; s
[8] =&gt; _
[9] =&gt; s
[10] =&gt; t
[11] =&gt; r
[12] =&gt; e
[13] =&gt; e
[14] =&gt; t
[15] =&gt; 2
[16] =&gt; }
)

But what I don't understand is why this does print the value of {address_street2}:

&lt;?php
echo 'line 2 is '.'{address_street2}';
?&gt;

Is there a way to check for the existence of a value in {address_street2} and not print that line if there is nothing in it?

Thanks,
-Mike

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzcyNDcxLWhvdy10by1zdXBwcmVzcy1ibGFuay1hZGRyZXNzLWxpbmUtMj90bXBsPW1hcmtkb3du) 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)
-

14 years 4 weeks ago [\#72675](#72675) by [Xavier](/forum/user/4105-xavier "View Xavier's Profile")  Replied by *[Xavier](/forum/user/4105-xavier "View Xavier's Profile")* on topic *[Re: How to suppress blank address line 2](/forum/4-how-to/72471-how-to-suppress-blank-address-line-2#72675 "Hello,  I'm trying to modify address / address&#95;template.php to suppress {address&#95;street2} if it is blank. However, I cannot get access to the value of {address&#95;street2} to check its length.  I can tell I do not have the value of {address&#95;street2} by adding this to the template:    That will print the label, rather than the value:  Array ( &#91;0&#93; =&gt; { &#91;1&#93; =&gt; a &#91;2&#93; =&gt; d &#91;3&#93; =&gt; d &#91;4&#93; =&gt; r &#91;5&#93; =&gt; e &#91;6&#93; =&gt; s &#91;7&#93; =&gt; s &#91;8&#93; =&gt; &#95; &#91;9&#93; =&gt; s &#91;10&#93; =&gt; t &#91;11&#93; =&gt; r &#91;12&#93; =&gt; e &#91;13&#93; =&gt; e &#91;14&#93; =&gt; t &#91;15&#93; =&gt; 2 &#91;16&#93; =&gt; } )  But what I don't understand is why this does print the value of {address&#95;street2}:    Is there a way to check for the existence of a value in {address&#95;street2} and not print that line if there is nothing in it?  Thanks, -Mike")*

Hi,

To display the address_street2 only if there is something in the address, add the tag "{address_street2}" in the view "address / address_template" and then edit the view "address / listing" and replace the line: Code:

$html=str_replace('{'.$fieldname.'}',$this-&gt;fieldsClass-&gt;show($field,$address-&gt;$fieldname),$html);

By: Code:

if($fieldname != 'address_street2' &#124;&#124; ($fieldname == 'address_street2' &amp;&amp; !empty($fieldname))){ $html=str_replace('{'.$fieldname.'}',$this-&gt;fieldsClass-&gt;show($field,$address-&gt;$fieldname),$html); }

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

- **[mkj101us](/forum/user/9513-mkj101us "View mkj101us's Profile")**
- [![mkj101us's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar9513.jpeg)](/forum/user/9513-mkj101us "View mkj101us's Profile") Topic Author
- [ Offline](/forum/user/9513-mkj101us)

Less More

- Posts: 12
- Thank you received: 0
-
-

14 years 3 weeks ago [\#73244](#73244) by [mkj101us](/forum/user/9513-mkj101us "View mkj101us's Profile")  Replied by *[mkj101us](/forum/user/9513-mkj101us "View mkj101us's Profile")* on topic *[Re: How to suppress blank address line 2](/forum/4-how-to/72471-how-to-suppress-blank-address-line-2#73244 "Hello,  I'm trying to modify address / address&#95;template.php to suppress {address&#95;street2} if it is blank. However, I cannot get access to the value of {address&#95;street2} to check its length.  I can tell I do not have the value of {address&#95;street2} by adding this to the template:    That will print the label, rather than the value:  Array ( &#91;0&#93; =&gt; { &#91;1&#93; =&gt; a &#91;2&#93; =&gt; d &#91;3&#93; =&gt; d &#91;4&#93; =&gt; r &#91;5&#93; =&gt; e &#91;6&#93; =&gt; s &#91;7&#93; =&gt; s &#91;8&#93; =&gt; &#95; &#91;9&#93; =&gt; s &#91;10&#93; =&gt; t &#91;11&#93; =&gt; r &#91;12&#93; =&gt; e &#91;13&#93; =&gt; e &#91;14&#93; =&gt; t &#91;15&#93; =&gt; 2 &#91;16&#93; =&gt; } )  But what I don't understand is why this does print the value of {address&#95;street2}:    Is there a way to check for the existence of a value in {address&#95;street2} and not print that line if there is nothing in it?  Thanks, -Mike")*

Hi Xavier,

I see what you are trying to do, however it seems that the layout in "address / address_template" is overridding what you are doing in "address / listing" and always adding a line for address_street2.

The contents of "address / listing" is:

&lt;?php
/**
* @package HikaShop for Joomla!
* @version 1.6.0
* @author hikashop.com
* @copyright (C) 2010-2012 HIKARI SOFTWARE. All rights reserved.
* @license GNU/GPLv3 [ www.gnu.org/licenses/gpl-3.0.html](http://www.gnu.org/licenses/gpl-3.0.html)
*/
defined('_JEXEC') or die('Restricted access');
?&gt;
{address_company}
{address_title} {address_firstname} {address_lastname}
{address_street}
{address_street2}
{address_post_code} {address_city} {address_country}
{address_state}
&lt;?php echo JText::sprintf('TELEPHONE_IN_ADDRESS','{address_telephone}');?&gt;

Thoughts?

Thanks,
-Mike

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzcyNDcxLWhvdy10by1zdXBwcmVzcy1ibGFuay1hZGRyZXNzLWxpbmUtMj90bXBsPW1hcmtkb3du) 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)
-

14 years 3 weeks ago [\#73317](#73317) by [Xavier](/forum/user/4105-xavier "View Xavier's Profile")  Replied by *[Xavier](/forum/user/4105-xavier "View Xavier's Profile")* on topic *[Re: How to suppress blank address line 2](/forum/4-how-to/72471-how-to-suppress-blank-address-line-2#73317 "Hello,  I'm trying to modify address / address&#95;template.php to suppress {address&#95;street2} if it is blank. However, I cannot get access to the value of {address&#95;street2} to check its length.  I can tell I do not have the value of {address&#95;street2} by adding this to the template:    That will print the label, rather than the value:  Array ( &#91;0&#93; =&gt; { &#91;1&#93; =&gt; a &#91;2&#93; =&gt; d &#91;3&#93; =&gt; d &#91;4&#93; =&gt; r &#91;5&#93; =&gt; e &#91;6&#93; =&gt; s &#91;7&#93; =&gt; s &#91;8&#93; =&gt; &#95; &#91;9&#93; =&gt; s &#91;10&#93; =&gt; t &#91;11&#93; =&gt; r &#91;12&#93; =&gt; e &#91;13&#93; =&gt; e &#91;14&#93; =&gt; t &#91;15&#93; =&gt; 2 &#91;16&#93; =&gt; } )  But what I don't understand is why this does print the value of {address&#95;street2}:    Is there a way to check for the existence of a value in {address&#95;street2} and not print that line if there is nothing in it?  Thanks, -Mike")*

Hi,

I think that the code given is in the file "address / address_template", if it's in the file "address / listing", delete the customizations by clicking on the dustbin in the listing of the views in HikaShop &gt; Display &gt; Views.
And then edit this view again to make the changes given.

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

- **[mkj101us](/forum/user/9513-mkj101us "View mkj101us's Profile")**
- [![mkj101us's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar9513.jpeg)](/forum/user/9513-mkj101us "View mkj101us's Profile") Topic Author
- [ Offline](/forum/user/9513-mkj101us)

Less More

- Posts: 12
- Thank you received: 0
-
-

14 years 3 weeks ago [\#73354](#73354) by [mkj101us](/forum/user/9513-mkj101us "View mkj101us's Profile")  Replied by *[mkj101us](/forum/user/9513-mkj101us "View mkj101us's Profile")* on topic *[Re: How to suppress blank address line 2](/forum/4-how-to/72471-how-to-suppress-blank-address-line-2#73354 "Hello,  I'm trying to modify address / address&#95;template.php to suppress {address&#95;street2} if it is blank. However, I cannot get access to the value of {address&#95;street2} to check its length.  I can tell I do not have the value of {address&#95;street2} by adding this to the template:    That will print the label, rather than the value:  Array ( &#91;0&#93; =&gt; { &#91;1&#93; =&gt; a &#91;2&#93; =&gt; d &#91;3&#93; =&gt; d &#91;4&#93; =&gt; r &#91;5&#93; =&gt; e &#91;6&#93; =&gt; s &#91;7&#93; =&gt; s &#91;8&#93; =&gt; &#95; &#91;9&#93; =&gt; s &#91;10&#93; =&gt; t &#91;11&#93; =&gt; r &#91;12&#93; =&gt; e &#91;13&#93; =&gt; e &#91;14&#93; =&gt; t &#91;15&#93; =&gt; 2 &#91;16&#93; =&gt; } )  But what I don't understand is why this does print the value of {address&#95;street2}:    Is there a way to check for the existence of a value in {address&#95;street2} and not print that line if there is nothing in it?  Thanks, -Mike")*

I'm sorry, yes that code I supplied is from "address / address_template" &amp; I added your if() statement to "address / listing" -- that scenario is where address_template is always adding a blank line for address_street2.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzcyNDcxLWhvdy10by1zdXBwcmVzcy1ibGFuay1hZGRyZXNzLWxpbmUtMj90bXBsPW1hcmtkb3du) 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)
-

14 years 3 weeks ago [\#73376](#73376) by [Xavier](/forum/user/4105-xavier "View Xavier's Profile")  Replied by *[Xavier](/forum/user/4105-xavier "View Xavier's Profile")* on topic *[Re: How to suppress blank address line 2](/forum/4-how-to/72471-how-to-suppress-blank-address-line-2#73376 "Hello,  I'm trying to modify address / address&#95;template.php to suppress {address&#95;street2} if it is blank. However, I cannot get access to the value of {address&#95;street2} to check its length.  I can tell I do not have the value of {address&#95;street2} by adding this to the template:    That will print the label, rather than the value:  Array ( &#91;0&#93; =&gt; { &#91;1&#93; =&gt; a &#91;2&#93; =&gt; d &#91;3&#93; =&gt; d &#91;4&#93; =&gt; r &#91;5&#93; =&gt; e &#91;6&#93; =&gt; s &#91;7&#93; =&gt; s &#91;8&#93; =&gt; &#95; &#91;9&#93; =&gt; s &#91;10&#93; =&gt; t &#91;11&#93; =&gt; r &#91;12&#93; =&gt; e &#91;13&#93; =&gt; e &#91;14&#93; =&gt; t &#91;15&#93; =&gt; 2 &#91;16&#93; =&gt; } )  But what I don't understand is why this does print the value of {address&#95;street2}:    Is there a way to check for the existence of a value in {address&#95;street2} and not print that line if there is nothing in it?  Thanks, -Mike")*

You address_template should be like that: Code:

{address_company} {address_title} {address_firstname} {address_lastname} {address_street}{address_street2} {address_post_code} {address_city} {address_state} {address_country} &lt;?php echo JText::sprintf('TELEPHONE_IN_ADDRESS','{address_telephone}');?&gt;

And if you want the second address (when filled) at the line, in the listing view replace with the code: Code:

if($fieldname != 'address_street2'){ $html=str_replace('{'.$fieldname.'}',$this-&gt;fieldsClass-&gt;show($field,$address-&gt;$fieldname),$html); }elseif($fieldname == 'address_street2' &amp;&amp; !empty($fieldname)){ $html= "&lt;br/&gt;".str_replace('{'.$fieldname.'}',$this-&gt;fieldsClass-&gt;show($field,$address-&gt;$fieldname),$html); }

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

- **[mkj101us](/forum/user/9513-mkj101us "View mkj101us's Profile")**
- [![mkj101us's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar9513.jpeg)](/forum/user/9513-mkj101us "View mkj101us's Profile") Topic Author
- [ Offline](/forum/user/9513-mkj101us)

Less More

- Posts: 12
- Thank you received: 0
-
-

14 years 3 weeks ago [\#73630](#73630) by [mkj101us](/forum/user/9513-mkj101us "View mkj101us's Profile")  Replied by *[mkj101us](/forum/user/9513-mkj101us "View mkj101us's Profile")* on topic *[Re: How to suppress blank address line 2](/forum/4-how-to/72471-how-to-suppress-blank-address-line-2#73630 "Hello,  I'm trying to modify address / address&#95;template.php to suppress {address&#95;street2} if it is blank. However, I cannot get access to the value of {address&#95;street2} to check its length.  I can tell I do not have the value of {address&#95;street2} by adding this to the template:    That will print the label, rather than the value:  Array ( &#91;0&#93; =&gt; { &#91;1&#93; =&gt; a &#91;2&#93; =&gt; d &#91;3&#93; =&gt; d &#91;4&#93; =&gt; r &#91;5&#93; =&gt; e &#91;6&#93; =&gt; s &#91;7&#93; =&gt; s &#91;8&#93; =&gt; &#95; &#91;9&#93; =&gt; s &#91;10&#93; =&gt; t &#91;11&#93; =&gt; r &#91;12&#93; =&gt; e &#91;13&#93; =&gt; e &#91;14&#93; =&gt; t &#91;15&#93; =&gt; 2 &#91;16&#93; =&gt; } )  But what I don't understand is why this does print the value of {address&#95;street2}:    Is there a way to check for the existence of a value in {address&#95;street2} and not print that line if there is nothing in it?  Thanks, -Mike")*

Thanks Xavier. That will work.

-Mike

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzcyNDcxLWhvdy10by1zdXBwcmVzcy1ibGFuay1hZGRyZXNzLWxpbmUtMj90bXBsPW1hcmtkb3du) 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.058 seconds

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