Keyword

Extra Field - Multi Select as a list?

  • Mike Dove
  • Mike Dove's Avatar Topic Author
  • Offline
  • New Member
More
14 years 6 months ago #80841 by Mike Dove
Extra Field - Multi Select as a list? was created by Mike Dove
Hi, is there anyway to chage the way K2 outputs data from an extra field with a multi-select-list?  Currently it out puts the slections as a non formatted string (i.e  item1, item2, item3) seperated by commas.Obviously at some point K2 has to read that these are seperate items and has to call them individually and insert the   ","    ...so would it be possible to render them as list items? instead?I have been looking through the various files in k2 and cannot find an place that this control might be edited...  can anyone give me a clue please?

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

More
14 years 6 months ago #80842 by Jiliko.net
Replied by Jiliko.net on topic Extra Field - Multi Select as a list?
Hi Mike,

You are right concerning the construction of the formatted string.

Take a look at the file 'components/com_k2/models/item.php' line 745.

Olivier

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

  • Mike Dove
  • Mike Dove's Avatar Topic Author
  • Offline
  • New Member
More
14 years 6 months ago #80843 by Mike Dove
Replied by Mike Dove on topic Extra Field - Multi Select as a list?
AHHHH!

thanks for that!

do you have any idea where I would need to insert the li open and close tags?

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

  • Mike Dove
  • Mike Dove's Avatar Topic Author
  • Offline
  • New Member
More
14 years 6 months ago #80844 by Mike Dove
Replied by Mike Dove on topic Extra Field - Multi Select as a list?
ok.. I have managed to get them into a (li) brackets by doing this :

$value=@implode('(/li)(li) ',$values);

, although it skips the first value.

i think there is something on the lines before that i need to change that would apply the brackets to EVERYTHING?

What I would like to do is add (li) wrapper to EVERY value aswell as give each (li) a class that is a copy of the option value so you output (please change in the tag brackets in your head ;)) :

(li class="value") value (/li)

for each selection..

(the reason for doing this is so i can apply css to the li individually and based upon the value)

i will keep experimenting but as i said my .php knowledge is very limited, if anyone could give me a hint it would be much apreciated!

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

More
14 years 6 months ago #80845 by Jiliko.net
Replied by Jiliko.net on topic Extra Field - Multi Select as a list?
Mike,

One solution is to add code in your item.php k2 template file and not to modifiy k2 core files.

in attachment, some code that could do the job but if the value contains special caracters like space, comma then the class of the li element won't work as desired.

Olivier
Attachments:

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

More
14 years 6 months ago #80846 by FeSys
Replied by FeSys on topic Extra Field - Multi Select as a list?
"Olivier Nolbert "
You Rock...

Olivier Nolbert said:Mike,
One solution is to add code in your item.php k2 template file and not to modifiy k2 core files.

in attachment, some code that could do the job but if the value contains special caracters like space, comma then the class of the li element won't work as desired.

Olivier

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

  • Mike Dove
  • Mike Dove's Avatar Topic Author
  • Offline
  • New Member
More
14 years 6 months ago #80847 by Mike Dove
Replied by Mike Dove on topic Extra Field - Multi Select as a list?
right.. gonna give this a go :) ta

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

  • Mike Dove
  • Mike Dove's Avatar Topic Author
  • Offline
  • New Member
More
14 years 6 months ago #80848 by Mike Dove
Replied by Mike Dove on topic Extra Field - Multi Select as a list?
right..

first of all THANK YOU SO MUCH Oliver.

to confirm your method works perfectly for standard extra feild setups i can confirm.


HOWEVER for me its not working quite as i need.. let me explain.

im actually designing something very non standard, I have been using a method to call extra fields individually and too custom locations as described in this tutorial :

community.getk2.org/forum/topics/tutorial-adding-googlemaps?commentId=3536014%3AComment%3A46239

what i have been doing is by adding (to my template/html/com_k2/templates/item.php)

(?php $custom = $this->item->extra_fields; ?)
(added at the top)

and calling my individual extra feilds using

(?php echo $custom[0]->value;?)
(added where i want o call a value (the number refers to the specific extra feild starting from 0))

is there anyway i can modify your suggested code to attach directly to one of these calls?

sorry for the trouble!

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

More
14 years 6 months ago #80849 by Jiliko.net
Replied by Jiliko.net on topic Extra Field - Multi Select as a list?
Mike,

In attachment an example of a php function that create an ul li structure with the extraField object passed

in your item.php

just use : (?php echo createLiWithExtraField($custom[0]);?)

Code not tested but should work

Olivier

Mike Dove said:right..
first of all THANK YOU SO MUCH Oliver.

to confirm your method works perfectly for standard extra feild setups i can confirm.


HOWEVER for me its not working quite as i need.. let me explain.

im actually designing something very non standard, I have been using a method to call extra fields individually and too custom locations as described in this tutorial :

community.getk2.org/forum/topics/tutorial-adding-googlemaps?...

what i have been doing is by adding (to my template/html/com_k2/templates/item.php)

(?php $custom = $this->item->extra_fields; ?)
(added at the top)

and calling my individual extra feilds using

(?php echo $custom[0]->value;?)
(added where i want o call a value (the number refers to the specific extra feild starting from 0))

is there anyway i can modify your suggested code to attach directly to one of these calls?

sorry for the trouble!
Attachments:

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

  • Mike Dove
  • Mike Dove's Avatar Topic Author
  • Offline
  • New Member
More
14 years 6 months ago #80850 by Mike Dove
Replied by Mike Dove on topic Extra Field - Multi Select as a list?
cool, where do I add that? to the

(?php $custom = $this->item->extra_fields; ?)

?

or seperatley?

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


Powered by Kunena Forum