display custom field output in unordered list

  • Posts: 103
  • Thank you received: 5
5 years 3 months ago #302014

-- 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:

<?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:
[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:
<?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:
value01,value01,value03,...
should't as default a blank between??
value01, value02, value03, ...

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

  • Posts: 81378
  • Thank you received: 13037
  • MODERATOR
5 years 3 months ago #302015

Hi,

You want to change the line:

echo '<li>' . implode( '</li><li>', $this->row->sportuse) . '</li>';
to:
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.

  • Posts: 103
  • Thank you received: 5
5 years 3 months ago #302025

perfect, thank you!

Last edit: 5 years 3 months ago by n00bster.

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

Time to create page: 0.057 seconds
Powered by Kunena Forum