Keyword

Fields to display in an article via php

  • Garrett Fry
  • Garrett Fry's Avatar Topic Author
  • Offline
  • New Member
More
10 years 1 month ago - 10 years 1 month ago #131430 by Garrett Fry
Fields to display in an article via php was created by Garrett Fry
So I am creating a extra fields for an article. I want those extra fields to display in that article via php (I am using the NoNumbers Sourcer for that).
So if I had a "All about BLUE Widgets" article with extra fields called "size" and "weight".
I want "size" and "weight" to be displayed in the body of the "All about BLUE Widgets" article.
And I would want the "size" and "weight" of the RED Widget to display in the article on "All about RED Widgets"

I should say here that I want the "size" and "weight" in a specific place--within the text of the body

Does that make sense? Is there a K2 plugin that will do this without php?

Is the php something like this???:
<?php
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query
->select('size')
->from('#__cck_store_widgets_specs')
$db->setQuery($query);
$widgetSize = $db->loadObjectList();
echo $widgetSize->get("size");
?>
Any help would be great.
Thanks

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

More
10 years 1 month ago #131431 by JoomlaWorks
Replied by JoomlaWorks on topic Re: Fields to display in an article via php
Extra fields are grouped so they can be assigned to one or more categories. If you need different sets of extra fields displayed in your content, assign your content to different categories and additionally create sets of extra fields and assign them accordingly to the these categories.

If you wish to display extra fields separately, you can use this feature added in K2 v2.6.2 getk2.org/blog/1068-k2-v262-now-available (use the extra field alias to directly call an extra field name or value). You can place these PHP calls anywhere in your item.php sub-template in K2.

You probably don't need a plugin to achieve the output you want. ;)

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