Integrated Custom Fields in My Component

For Joomla! 3.x Coding related discussions, please use: http://groups.google.com/group/joomla-dev-general

Moderator: ooffick

Forum rules
Please use the mailing list here: http://groups.google.com/group/joomla-dev-general rather than this forum.
User avatar
liubov
Joomla! Apprentice
Joomla! Apprentice
Posts: 23
Joined: Thu Sep 10, 2009 2:00 am

Integrated Custom Fields in My Component

Postby liubov » Tue Sep 12, 2017 3:07 pm

I've read and read again the related Joomla doc, but nothing work, and it's not really clear.
https://docs.joomla.org/J3.x:Adding_custom_fields/Implement_into_your_component

I want to create and integrate some CF in my component, but following this method, i finaly do not see the 2 menus Fields & Groups in my component Menu (Left column).

has Anybody get a clear and valid 'How To Do'.

thanks a lot.
Developper of JBreeding Manager http://www.jbreeding.fr/
Themes Breeding: Cats & Dogs, Horses, Rabbits ...
Liubov Siberian Husky http://www.liubov.net/

SharkyKZ
Joomla! Guru
Joomla! Guru
Posts: 802
Joined: Fri Jul 05, 2013 10:35 am
Location: Unknown

Re: Integrated Custom Fields in My Component

Postby SharkyKZ » Tue Sep 12, 2017 4:41 pm

Have you created a component helper? If not, create a file called example.php (example = your component's name) in /administrator/components/com_example/helpers/ and add this to the file:

Code: Select all

defined('_JEXEC') or die;
class ExampleHelper extends JHelperContent
{
public static function addSubmenu($vName)
   {
if (JComponentHelper::isEnabled('com_fields'))
{
   JHtmlSidebar::addEntry(
      JText::_('JGLOBAL_FIELDS'),
      'index.php?option=com_fields&context=com_example.item',
      $vName == 'fields.fields'
   );

   JHtmlSidebar::addEntry(
      JText::_('JGLOBAL_FIELD_GROUPS'),
      'index.php?option=com_fields&view=groups&context=com_example.item',
      $vName == 'fields.groups'
   );
}

}
}

Replace example with the name of your component.

Load the helper in the default controller (/administrator/components/com_example/controller.php) by adding this line inside display function:

Code: Select all

JLoader::register('ExampleHelper', JPATH_ADMINISTRATOR . '/components/com_example/helpers/example.php');

User avatar
liubov
Joomla! Apprentice
Joomla! Apprentice
Posts: 23
Joined: Thu Sep 10, 2009 2:00 am

Re: Integrated Custom Fields in My Component

Postby liubov » Tue Sep 12, 2017 9:30 pm

yes, my component follows the standard of API 3.7, so right now,

-> I add the xml code for fields and groups rules in access.xml and xml code to activate CF in my params in config.xml.
-> I also add the code in my helper/helper.php, but not sur that 'com_jbreeding.item' is the good syntax ?!?

Code: Select all

               
                JHtmlSidebar::addEntry(
                    JText::_('JGLOBAL_FIELDS'),
                    'index.php?option=com_fields&context=com_jbreeding.item',
                    $vName == 'fields.fields' );

                JHtmlSidebar::addEntry(
                    JText::_('JGLOBAL_FIELD_GROUPS'),
                    'index.php?option=com_fields&context=com_jbreeding.item',
                    $vName == 'fields.groups' );


normaly, I should find Fields and Group fields at the end of my componen menu list, but nothing!
Image

thanks
Developper of JBreeding Manager http://www.jbreeding.fr/
Themes Breeding: Cats & Dogs, Horses, Rabbits ...
Liubov Siberian Husky http://www.liubov.net/

SharkyKZ
Joomla! Guru
Joomla! Guru
Posts: 802
Joined: Fri Jul 05, 2013 10:35 am
Location: Unknown

Re: Integrated Custom Fields in My Component

Postby SharkyKZ » Wed Sep 13, 2017 5:34 am

Do you add other sidebar items the same way?

User avatar
liubov
Joomla! Apprentice
Joomla! Apprentice
Posts: 23
Joined: Thu Sep 10, 2009 2:00 am

Re: Integrated Custom Fields in My Component

Postby liubov » Wed Sep 13, 2017 6:44 am

You right !
I do not use this method to display my menus in this function. so, i corrected that and I see the 2 menus now ...

Code: Select all

// addScript custom fields
$menu[] = array(JText::_('JGLOBAL_FIELDS'), 'index.php?option=com_fields&context=com_jbreeding.portee.gestionduneportee', 'fields.fields', 'jbreeding_fields');

$menu[] = array(JText::_('JGLOBAL_FIELD_GROUPS'), 'index.php?option=com_fields&view=groups&context=com_jbreeding.portee.gestionduneportee', 'fields.groups', 'jbreeding_groupsfields');   
       
return $menu;

Developper of JBreeding Manager http://www.jbreeding.fr/
Themes Breeding: Cats & Dogs, Horses, Rabbits ...
Liubov Siberian Husky http://www.liubov.net/

User avatar
liubov
Joomla! Apprentice
Joomla! Apprentice
Posts: 23
Joined: Thu Sep 10, 2009 2:00 am

Re: Integrated Custom Fields in My Component

Postby liubov » Wed Sep 13, 2017 12:10 pm

yeah! works fine now.
I can create customs fields for my component.
Image

thanks for your help :D

Marc
Developper of JBreeding Manager http://www.jbreeding.fr/
Themes Breeding: Cats & Dogs, Horses, Rabbits ...
Liubov Siberian Husky http://www.liubov.net/

User avatar
liubov
Joomla! Apprentice
Joomla! Apprentice
Posts: 23
Joined: Thu Sep 10, 2009 2:00 am

Re: Integrated Custom Fields in My Component

Postby liubov » Mon Sep 18, 2017 10:01 am

Hi,

I am now able to create some custom fields for a context of my component.

I try to call the Fields Tab in my Edit Form, in order to fill the values.

Do you know how to do that ?

thxs
Developper of JBreeding Manager http://www.jbreeding.fr/
Themes Breeding: Cats & Dogs, Horses, Rabbits ...
Liubov Siberian Husky http://www.liubov.net/


Return to “Joomla! 3.x Coding”

Who is online

Users browsing this forum: No registered users and 2 guests