Keyword

Specifics extra fields with php

  • Langagemachine
  • Langagemachine's Avatar Topic Author
  • Offline
  • New Member
More
2 weeks 2 days ago #171925 by Langagemachine
Langagemachine created the topic: Specifics extra fields with php
Hi community,


I install a good free plugin from joomla.impression-estudio.gr wich load php code.
I make example and it work.
This is the example code
<?php
$body = JResponse::getBody();
$body = str_replace('#DATE#', date("Y-m-d h:i:s"), $body);
JResponse::setBody($body);
?>
When i add #DATE# in a custom joomla modulle it will be showned.
The custom code is replacing this text with the php code :)



I try to do the same with a specific k2 extra field and i test, i test without succes :(

<?php
$k2obj = new K2ModelItem();
$fields = $k2obj->getItemExtraFields($item->extra_fields, $item);?>
<?php echo $item->extraFields->ALIASFIELD->value; ?>

$body = JResponse::getBody();
$body = str_replace('#TEMP#', $temp, $body); JResponse::setBody($body);
JResponse::setBody($body); ?>

Have you an idea to get issue ?


I see this code yet for insert in module
<?php
if ( (isset($item->extraFields->ALIAS->value)) && ($item->extraFields->ALIASALIASFIELD->value!='') ) {
echo $item->extraFields->ALIAS->value;
}
?>

Regards.

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

  • Fotis
  • Fotis's Avatar
  • Offline
  • Administrator
  • JoomlaWorks Support Team
More
2 weeks 1 day ago #171944 by Fotis
Fotis replied the topic: Specifics extra fields with php
I can't possibly know how that plugin works. Why not ask the developer of that plugin first?


If you use & love K2, please take a moment to add your review and rate it
at the Joomla Extensions Directory: extensions.joomla.org/extension/k2/


IMPORTANT: Please search the forum before posting a question!

JoomlaWorks Support Team Member

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

  • Langagemachine
  • Langagemachine's Avatar Topic Author
  • Offline
  • New Member
More
2 weeks 14 hours ago #171952 by Langagemachine
Langagemachine replied the topic: Specifics extra fields with php
Yes,
I already asked :)
THe pugin is not for k2 specifically.
This is not the objectif of the developer. This is generally for php page ;)

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

  • Fotis
  • Fotis's Avatar
  • Offline
  • Administrator
  • JoomlaWorks Support Team
More
1 week 2 days ago #171977 by Fotis
Fotis replied the topic: Specifics extra fields with php
OK, try this:
K2Model::addIncludePath(JPATH_SITE.'/components/com_k2/models');
$model = K2Model::getInstance('Item', 'K2Model');
$item = $model->prepareItem('ITEM_ID_HERE', 'item', '');

...and then do "$item->extraFields->ALIASFIELD->value".


If you use & love K2, please take a moment to add your review and rate it
at the Joomla Extensions Directory: extensions.joomla.org/extension/k2/


IMPORTANT: Please search the forum before posting a question!

JoomlaWorks Support Team Member

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

Moderators: william white

Powered by Kunena Forum