Keyword

How to get echo extra field values by number?

  • SocheatICT
  • SocheatICT's Avatar Topic Author
  • Offline
  • New Member
More
11 years 1 month ago #119696 by SocheatICT
Hi All team members

Please help me!


How to get echo extra field values by number?

I used this code <?php echo $extraField->value; ?>

But result show title of value.

So I need code that echo number of values instead of name,

<?php echo $extraField->xxxx; ?>

Result will be , 1,2,3,4 or 10

Please kindly provide small effective code for this.

Thanks, I really love K2.

Best Regards,

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
11 years 1 month ago #119697 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: How to get echo extra field values by number?
First of all please do not reply to spammers,
I click on the usernames and ban them. If you reply to the thread your username appears at the top. It 's kinda risky.

The value will output the value you set in the backend.
Make sure you are using ->value and not ->name in your template.

If you want to render a specific extrafield read this post please:
getk2.org/community/New-to-K2-Ask-here-first/171284-Where-to-edit-K2-after-Item-Fields

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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

  • SocheatICT
  • SocheatICT's Avatar Topic Author
  • Offline
  • New Member
More
11 years 1 month ago - 11 years 1 month ago #119698 by SocheatICT
Replied by SocheatICT on topic Re: How to get echo extra field values by number?
Hi Krikor Boghossian

Thanks so much for your time with support me, I click on your link and try it, but it's still ExtraFiled value as (label) instead of number ordering value as I need.

As i saw in database: written as , Example, "value":1, "value":2,....

below as in DB

{"name":"One","value":1,"target":null,"alias":"test","required":1,"showNull":0},{"name":"Two","value":2,"target":null,"alias":"test","required":1,"showNull":0},{"name":"Three","value":3,"target":null,"alias":"test","required":1,"showNull":0}

I really need value in number as I highlighted in red color:

So what i need get value from as ordering number as 1 or 2 or 3, because need to make dynamic link for search function.

Thanks

Best Regards

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
11 years 3 weeks ago #119699 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: How to get echo extra field values by number?
Which type of extrafields are you using?

For links the $this->item->extraFields->EXTRAFIELDALIASHERE->value will output the entire link as an HTML element. If you just the href value you can either use a text extrafield or use a PHP eg/exp to get the link's href attribute.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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

  • SocheatICT
  • SocheatICT's Avatar Topic Author
  • Offline
  • New Member
More
11 years 3 weeks ago #119700 by SocheatICT
Replied by SocheatICT on topic Re: How to get echo extra field values by number?
Hi Krikor Boghossian

Thanks for you reply, but I try add this code

echo $this->item->extraFields->EXTRAFIELDALIASHERE->value; Result = " No thing "

Seem not work, and no display anything.

Any solution?

Thanks so much for your time, and I appreciate you a lot!

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
11 years 3 weeks ago #119701 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: How to get echo extra field values by number?
You 're welcome.

Go to the backend and open the extrafields section of K2. Make sure the extrafield alias is the same that you are using in your code. PS it is case-sensitive as well.

Several characters and spaces will be stripped so maybe you are using the wrong alias.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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


Powered by Kunena Forum