Keyword

Specifics extra fields with php

  • Langagemachine
  • Langagemachine's Avatar Topic Author
  • Offline
  • New Member
More
4 years 10 months ago #171925 by Langagemachine
Specifics extra fields with php was created by Langagemachine
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.

More
4 years 10 months ago #171944 by JoomlaWorks
Replied by JoomlaWorks on topic Specifics extra fields with php
I can't possibly know how that plugin works. Why not ask the developer of that plugin first?

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

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

  • Langagemachine
  • Langagemachine's Avatar Topic Author
  • Offline
  • New Member
More
4 years 10 months ago #171952 by Langagemachine
Replied by Langagemachine on 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.

More
4 years 10 months ago #171977 by JoomlaWorks
Replied by JoomlaWorks on 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".

Fotis / 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