The Joomla! Forum ™



Forum rules


Please use the mailing list here: http://groups.google.com/group/joomla-dev-general rather than this forum.



Post new topic Reply to topic  [ 16 posts ] 
Author Message
PostPosted: Wed Jul 04, 2012 1:16 pm 
Joomla! Enthusiast
Joomla! Enthusiast

Joined: Sun Jul 12, 2009 12:04 pm
Posts: 169
Hi,

I've added a rule into the config.xml of my component.
set the rules path into config.xml:
Code:
<config addrulepath="/administrator/components/com_mycomponent/models/rules">

set the ruled field:
Code:
<field name="field_name" type="text" default="xx"
label="COM_MYCOMPONENT_FIELD_NAME_LABEL" description="COM_MYCOMPONENT_FIELD_NAME_DESC"
size="10" validate="myrule" />

and created the myrule.php file with proper code into /administrator/components/com_mycomponent/models/rules folder.

It works and rule is applied BUT the warning message I get is:
Quote:
Invalid field: COM_MYCOMPONENT_FIELD_NAME_LABEL

Language variable of my component is not interpreted. :eek:

Why that pb comes from and how can I fixe it ?

Thanks


Top
 Profile  
 
PostPosted: Wed Jul 11, 2012 7:56 pm 
Joomla! Explorer
Joomla! Explorer

Joined: Fri Nov 11, 2011 9:43 pm
Posts: 435
Location: Chicago, IL
not 100%, but the addrulepath attribute isn't needed unless your referencing data from another component. Are you having any other issues with your language file constants not displaying? How are you adding the files in the Joomla Manifest?


Top
 Profile  
 
PostPosted: Wed Jul 11, 2012 8:44 pm 
Joomla! Enthusiast
Joomla! Enthusiast

Joined: Sun Jul 12, 2009 12:04 pm
Posts: 169
Quote:
Are you having any other issues with your language file constants not displaying?

No, it's the only one.
Quote:
How are you adding the files in the Joomla Manifest?

like this:

Quote:
<files folder="admin">
<!-- Admin Main File Copy Section -->
<filename>access.xml</filename>
<filename>config.xml</filename>
<filename>mycomponent.php</filename>
<filename>controller.php</filename>
<filename>download.php</filename>
<filename>mycomponent.css</filename>
<filename>index.html</filename>
<!-- Folders Section -->
<folder>sql</folder>
<folder>tables</folder>
<folder>models</folder>
<folder>views</folder>
<folder>controllers</folder>
<folder>helpers</folder>
</files>

May be com_config component has no access to component language file ?


Top
 Profile  
 
PostPosted: Wed Jul 11, 2012 8:53 pm 
Joomla! Explorer
Joomla! Explorer

Joined: Fri Nov 11, 2011 9:43 pm
Posts: 435
Location: Chicago, IL
It doesn't look like the language folder is listed in the Admin section of the manifest, is that were the error is occurring in the admin interface?


Top
 Profile  
 
PostPosted: Thu Jul 12, 2012 5:41 am 
Joomla! Enthusiast
Joomla! Enthusiast

Joined: Sun Jul 12, 2009 12:04 pm
Posts: 169
oh sorry, you talk about the path of the language xml files.
They are defined like this in the manifest:

Code:
<languages folder="admin">
         <language tag="en-GB">language/en-GB/en-GB.com_mycomponent.ini
         </language>
         <language tag="en-GB">language/en-GB/en-GB.com_mycomponent.sys.ini
         </language>
         <language tag="fr-FR">language/fr-FR/fr-FR.com_mycomponent.ini
         </language>
         <language tag="fr-FR">language/fr-FR/fr-FR.com_mycomponent.sys.ini
         </language>
      </languages>


Top
 Profile  
 
PostPosted: Thu Jul 12, 2012 3:37 pm 
Joomla! Explorer
Joomla! Explorer

Joined: Fri Nov 11, 2011 9:43 pm
Posts: 435
Location: Chicago, IL
In the text field doc at Joomla there doesn't seem to be a validate parameter. If you try removing that attribute in you field definition xml do you still get the error?

http://docs.joomla.org/Text_form_field_type


Top
 Profile  
 
PostPosted: Tue Jul 17, 2012 6:16 am 
Joomla! Enthusiast
Joomla! Enthusiast

Joined: Sun Jul 12, 2009 12:04 pm
Posts: 169
Quote:
If you try removing that attribute in you field definition xml do you still get the error?

Yes, the error still remains. :(
I just can't figure out where that pb comes from.


Top
 Profile  
 
PostPosted: Tue Jul 17, 2012 4:07 pm 
Joomla! Explorer
Joomla! Explorer

Joined: Fri Nov 11, 2011 9:43 pm
Posts: 435
Location: Chicago, IL
Quote:
Invalid field: COM_MYCOMPONENT_FIELD_NAME_LABEL


Try changing the Language Definition Constant to something without NAME, as Joomla has implemented a strict naming convention for their language definition files. Try something like this:

Code:
COM_MYCOMPONENT_FIELD_TESTNAME_LABEL


Just to see if it still kicks out the error.


Top
 Profile  
 
PostPosted: Tue Jul 17, 2012 5:44 pm 
Joomla! Enthusiast
Joomla! Enthusiast

Joined: Sun Jul 12, 2009 12:04 pm
Posts: 169
I've already did that, but I still get the error. ???


Top
 Profile  
 
PostPosted: Tue Jul 17, 2012 6:20 pm 
Joomla! Explorer
Joomla! Explorer

Joined: Fri Nov 11, 2011 9:43 pm
Posts: 435
Location: Chicago, IL
In your global configuration, what level do you have error checking on? If you disable it does the warning go away?


Top
 Profile  
 
PostPosted: Tue Jul 17, 2012 8:00 pm 
Joomla! Enthusiast
Joomla! Enthusiast

Joined: Sun Jul 12, 2009 12:04 pm
Posts: 169
I enabled both debog mode and debog language but the error still remains.
Language file is properly loaded yet and there's no error.
Here's the language indicators in my warning message:
Quote:
??**Invalid field: ??COM_MYCOMPONENT_FIELD_TESTNAME_LABEL??**??


Top
 Profile  
 
PostPosted: Tue Jul 17, 2012 9:21 pm 
Joomla! Explorer
Joomla! Explorer

Joined: Fri Nov 11, 2011 9:43 pm
Posts: 435
Location: Chicago, IL
Where are you getting this error? On screen as a xdebug dump, in your apache2 error log or a Joomla System Message displayed in the <jdoc:include type="message" /> tag?


Top
 Profile  
 
PostPosted: Wed Jul 18, 2012 8:14 am 
Joomla! Enthusiast
Joomla! Enthusiast

Joined: Sun Jul 12, 2009 12:04 pm
Posts: 169
If you enable the Debug Language option in the global configuration, all of the language variables are checked.
** means it's ok, and ?? means the language variable has pb or is missing


Top
 Profile  
 
PostPosted: Wed Jul 18, 2012 3:47 pm 
Joomla! Explorer
Joomla! Explorer

Joined: Fri Nov 11, 2011 9:43 pm
Posts: 435
Location: Chicago, IL
On last idea, I remember having to do this to get my language files to populate, I've never used the feature you mentioned before though. Here you posted you language files reference in you component manifest:

Code:
<languages folder="admin">
         <language tag="en-GB">language/en-GB/en-GB.com_mycomponent.ini
         </language>
         <language tag="en-GB">language/en-GB/en-GB.com_mycomponent.sys.ini
         </language>
         <language tag="fr-FR">language/fr-FR/fr-FR.com_mycomponent.ini
         </language>
         <language tag="fr-FR">language/fr-FR/fr-FR.com_mycomponent.sys.ini
         </language>
      </languages>


Try removing or commenting out these entries, and add the files by adding a:

Code:
<folder>language</folder>


Entry under both the Site and Admin folders. The method above is depreciated, and maybe the errors are tied to that.

Quote:
This tag considered to be deprecated since Joomla! 1.6. We encourage you to put extension 's language files in extension folder and Joomla! is responsible for loading of required language files.


http://docs.joomla.org/Manifest_files

It's a long shot, but that's where we're at!

???


Top
 Profile  
 
PostPosted: Wed Jul 18, 2012 3:50 pm 
Joomla! Explorer
Joomla! Explorer

Joined: Fri Nov 11, 2011 9:43 pm
Posts: 435
Location: Chicago, IL
Good idea. I pasted the table class code from the example component you develop in the new Joomla 2.5 Programming Book. Hopefully that saves you a little time.

Code:
/**
 * @copyright   Copyright (C) 2011 Mark Dexter and Louis Landry. All rights reserved.
 * @license      GNU General Public License version 2 or later; see LICENSE.txt
 */

// No direct access
defined('_JEXEC') or die;

class JoomprosubsTableSubscription extends JTable
{
   /**
    * Constructor
    *
    * @param JDatabase A database connector object
    */
   public function __construct(&$db)
   {
      parent::__construct('#__joompro_subscriptions', 'id', $db);
   }

   /**
    * Overload the store method for the Subscriptions table.
    *
    * @param   boolean   Toggle whether null values should be updated.
    * @return   boolean   True on success, false on failure.
    */
   public function store($updateNulls = false)
   {
      $date   = JFactory::getDate();
      $user   = JFactory::getUser();
      if ($this->id) {
         // Existing item
         $this->modified   = $date->toMySQL();
         $this->modified_by   = $user->get('id');
      } else {
         // New subscription. Created and created_by field can be set by the user,
         // so we don't touch either of these if they are set.
         if (!intval($this->created)) {
            $this->created = $date->toMySQL();
         }
         if (empty($this->created_by)) {
            $this->created_by = $user->get('id');
         }
      }

      // Verify that the alias is unique
      $table = JTable::getInstance('subscription', 'joomprosubsTable');
      if ($table->load(array('alias'=>$this->alias,'catid'=>$this->catid)) && ($table->id != $this->id || $this->id==0)) {
         $this->setError(JText::_('COM_JOOMPROSUBS_ERROR_UNIQUE_ALIAS'));
         return false;
      }
      // Attempt to store the user data.
      return parent::store($updateNulls);
   }

   /**
    * Overloaded check method to ensure data integrity.
    *
    * @return   boolean   True on success.
    */
   public function check()
   {
      // check for existing name
      $db = $this->_db;
      $query = $db->getQuery(true);
      $query->select('id');
      $query->from($db->quoteName('#__joompro_subscriptions'));
      $query->where('title = ' . $db->quote($this->title) .
         ' AND catid = ' . (int) $this->catid);
      $db->setQuery($query);

      $xid = intval($db->loadResult());
      if ($xid && $xid != intval($this->id)) {
         $this->setError(JText::_('COM_JOOMPROSUBS_ERR_TABLES_NAME'));
         return false;
      }

      if (empty($this->alias)) {
         $this->alias = $this->title;
      }
      $this->alias = JApplication::stringURLSafe($this->alias);
      if (trim(str_replace('-','',$this->alias)) == '') {
         $this->alias = JFactory::getDate()->format("Y-m-d-H-i-s");
      }

      // Check the publish down date is not earlier than publish up.
      if (intval($this->publish_down) > 0 && $this->publish_down < $this->publish_up) {
         // Swap the dates.
         $temp = $this->publish_up;
         $this->publish_up = $this->publish_down;
         $this->publish_down = $temp;
      }

      return true;
   }
}


Top
 Profile  
 
PostPosted: Wed Jul 18, 2012 4:46 pm 
Joomla! Enthusiast
Joomla! Enthusiast

Joined: Sun Jul 12, 2009 12:04 pm
Posts: 169
Ok. I removed the old language entries from the manifest and replace them with a folder entry.
Unfortunately the error desperately remains. :(
If I have time I would try to create a rule for a standard component as Weblink for example and see if I get the same error.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 16 posts ] 



Who is online

Users browsing this forum: No registered users and 19 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group