Keyword

If a certain extra field exists

  • Darren Pinder
  • Darren Pinder's Avatar Topic Author
  • Offline
  • New Member
More
15 years 1 month ago #70890 by Darren Pinder
If a certain extra field exists was created by Darren Pinder
Hey there,

I'm hoping you can help me with this issue. I've specified some extra fields in the K2 extra field area, however in PHP I want to write some code that looks for a specific extra field value and displays some code depending on whether it's found.

My overall goal is for the PHP code to look for whether the extra field "download" has a URL in it, and if it does, display some HTML code that includes the extra field value.

Sadly I'm a PHP n00b, and no idea how to do this.

Thanks

Darren

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

More
15 years 1 month ago #70891 by Jesse Dundon
Replied by Jesse Dundon on topic If a certain extra field exists
Darren-

If you are calling the fields directly into the template, this is an easy one. I just tested the attached approach and it works fine...
Attachments:

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

  • Darren Pinder
  • Darren Pinder's Avatar Topic Author
  • Offline
  • New Member
More
15 years 1 month ago #70892 by Darren Pinder
Replied by Darren Pinder on topic If a certain extra field exists
Jesse,

Thank you! That's solved my problem, and helped clean up my code elsewhere too!

Would you mind explaining whether an adaption of this code is possible...

If an extra field $custom is called "video" then do an action, instead of looking for an extra field by it's array index? So where you've got $custom[0], is it possible to do something like $custom so that I don't have to get confused with array indexes and use field names instead?

I guess I could even take that one step further and have something like $custom =='yes' where the value is "yes"?

Many thanks for your help

Darren

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

More
15 years 1 month ago #70893 by Albert
Replied by Albert on topic If a certain extra field exists
Thanks for this, This should be a sticky.

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

  • Tiago Manuel da Costa Silva
  • Tiago Manuel da Costa Silva's Avatar
  • Offline
  • Junior Member
More
14 years 3 months ago #70894 by Tiago Manuel da Costa Silva
Replied by Tiago Manuel da Costa Silva on topic If a certain extra field exists
Hi Daren, do you have the answers for your questions yet? I liked the ideia, actually it would be very handy for me right know.

Darren Pinder said:Jesse,
Thank you! That's solved my problem, and helped clean up my code elsewhere too!

Would you mind explaining whether an adaption of this code is possible...

If an extra field $custom is called "video" then do an action, instead of looking for an extra field by it's array index? So where you've got $custom[0], is it possible to do something like $custom so that I don't have to get confused with array indexes and use field names instead?

I guess I could even take that one step further and have something like $custom =='yes' where the value is "yes"?

Many thanks for your help

Darren

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

More
14 years 6 hours ago #70895 by strummsteel
Replied by strummsteel on topic If a certain extra field exists
Can anyone help me?

I cant seem to make this code work. Where do I input it if i want to call custom fields in a list view? in category_item_links.php right? where there specifically?

I'm trying to make a listing with the items and some extra fields side by side.

community.getk2.org/forum/topics/custom-fields-and-list-view

Thanks in advance

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

  • Tiago Manuel da Costa Silva
  • Tiago Manuel da Costa Silva's Avatar
  • Offline
  • Junior Member
More
13 years 11 months ago #70896 by Tiago Manuel da Costa Silva
Replied by Tiago Manuel da Costa Silva on topic If a certain extra field exists
Hi, tell me what specifically what do you want to do. Thn i could try to help you

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

More
13 years 11 months ago #70897 by strummsteel
Replied by strummsteel on topic If a certain extra field exists
Hi,

I have setup a custom template for our website.

We need a way to post job listings. Anyway I used the K2 extra fields to key in some form based content.

web2.irri.org/our-people/come-work-with-us/current-vacancies...

However when i list the job items, it in a boring list

web2.irri.org/our-people/come-work-with-us/current-vacancies

Is there a way for me to call some items to appear in a list?

example

Job Title - Job Location - Date Posted - Closing Date

Being able to sort this would be a bonus too!!

I notice that there is a code to call extra fields here community.getk2.org/forum/topics/if-a-certain-extra-field but i cant seem to get it to work.

I'm pretty handy with CSS but a poor PHP coder, sorry.

Maybe anyone can help me? Thanks in advance for your help.

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


Powered by Kunena Forum