Keyword

Add custom fields to k2 content module -> Error

  • Johann Scharfetter
  • Johann Scharfetter's Avatar Topic Author
  • Offline
  • Senior Member
More
10 years 10 months ago - 10 years 10 months ago #120505 by Johann Scharfetter
Add custom fields to k2 content module -> Error was created by Johann Scharfetter
K2 v2.6.5

Hi,

I tried to add selected custom fields to k2 content module.

When I do it in item.php or category_item.php it works fine, but when I do it in the content module I get the following error:

Fatal error: Using $this when not in object context in /homez.428/monpetit/www/modules/mod_k2_content/tmpl/Talleres-inicio/default.php on line 75

Log in  or Create an account to join the conversation.

More
10 years 10 months ago - 10 years 10 months ago #120506 by Vitaly
You can now(ver.2.6.X) just call any extra_field you need via code
Log in  or Create an account to join the conversation.

  • olsen
  • olsen's Avatar
  • Offline
  • Elite Member
  • Joomla and K2 Freelancer
More
10 years 10 months ago #120507 by olsen
What vitaly say it is the right way to do it instead call the extrafields by its position on the array.
Anyway if you encounter troubles when calling the extarfield make the call without $this->, i mean like this:

$item->extrafields->ALIAS->name

Didn't solve your issues?? Why dont you consider hire me? Email me or contact me www.xevedigital.com for details

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

  • Johann Scharfetter
  • Johann Scharfetter's Avatar Topic Author
  • Offline
  • Senior Member
More
10 years 10 months ago - 10 years 10 months ago #120508 by Johann Scharfetter
Replied by Johann Scharfetter on topic Re: Add custom fields to k2 content module -> Error
Thank you for your kind answers.

I tried to do what you suggested, but get errors.


When I put follwoing the code
Notice: Undefined property: stdClass::$extrafields in /homez.428/monpetit/www/modules/mod_k2_content/tmpl/Talleres-inicio/default.php on line 72

Notice: Trying to get property of non-object in /homez.428/monpetit/www/modules/mod_k2_content/tmpl/Talleres-inicio/default.php on line 72

Notice: Trying to get property of non-object in /homez.428/monpetit/www/modules/mod_k2_content/tmpl/Talleres-inicio/default.php on line 72


__________________

When I put follwoing the code
Fatal error: Using $this when not in object context in /homez.428/monpetit/www/modules/mod_k2_content/tmpl/Talleres-inicio/default.php on line 72

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

  • Yiota
  • Yiota's Avatar
  • Visitor
10 years 10 months ago #120509 by Yiota
You are missing a semicolon at the end of your statement. It should be:
<?php echo $item->extraFields->Fecha->value; ?>

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

  • Johann Scharfetter
  • Johann Scharfetter's Avatar Topic Author
  • Offline
  • Senior Member
More
10 years 10 months ago #120510 by Johann Scharfetter
Replied by Johann Scharfetter on topic SOLVED! Add custom fields to k2 content module
Hello!

It is workin now.
The problem was not the semicolon but the F in extrafields it must be with upper case. 'extraFields'

working code
Log in  or Create an account to join the conversation.

  • Yiota
  • Yiota's Avatar
  • Visitor
10 years 10 months ago #120511 by Yiota
You are right. Didn't see that one.
Glad you worked it out. :)

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

More
9 years 11 months ago #120512 by baggiesmad

scharfet wrote: Hello!

It is workin now.
The problem was not the semicolon but the F in extrafields it must be with upper case. 'extraFields'

working code

Log in  or Create an account to join the conversation.