Skip to main content

display custom field output in unordered list

More
7 years 9 months ago #302014 by n00bster
-- HikaShop version -- : 4.0.1
-- Joomla version -- : 3.9.1
-- PHP version -- : 7.2

i have setup a multiselect field where i defined some default values. i display the output right now with this code:
Code:
<?php if(isset($this->row->sportuse) && !empty($this->row->sportuse)) {echo $this->row->sportuse; } ?>
but what i need is the values presented in a html list like the following sample:
Code:
[ul] [li]value 01[/li] [li]value 02[/li] [li]...[/li] [/ul]
i did a lot of testing but without a working result right now, this is what i have but as i sad, it does not working:
Code:
<?php if(isset($this->row->sportuse) && !empty($this->row->sportuse)) { echo '<ul>'; echo '<li>' . implode( '</li><li>', $this->row->sportuse) . '</li>'; echo '</ul>'; } ?>
has anyone here a working code to show the values in a list and could give me some inputs. that would be very nice.



i also noticed mean while i'm working on the list output, that the normal output, without lists, between the values are no spaces/blanks:
Code:
value01,value01,value03,...
should't as default a blank between??
Code:
value01, value02, value03, ...

Please Log in or Create an account to join the conversation.

More
7 years 9 months ago #302015 by nicolas
Hi,

You want to change the line:
Code:
echo '<li>' . implode( '</li><li>', $this->row->sportuse) . '</li>';
to:
Code:
foreach(explode(',',$this->row->sportuse) as $s){ echo '<li>' . $s . '</li>'; }
It's normal there is no space after the commas since you're displaying the raw data from the database. If however you let HikaShop display the custom field value itself, it will have a space after the commas as the custom field system will process the data:
monosnap.com/file/cluOz8BSQLTknlKaxvaspyoqfdHZOP
The following user(s) said Thank You: n00bster

Please Log in or Create an account to join the conversation.

More
7 years 9 months ago - 7 years 9 months ago #302025 by n00bster
perfect, thank you!
Last edit: 7 years 9 months ago by n00bster.

Please Log in or Create an account to join the conversation.

Time to create page: 0.188 seconds
Powered by Kunena Forum