Elxis CMS Forum
Extensions => Components => Topic started by: lsoker on December 13, 2013, 10:52:05
-
Hello everyone,
I building a custom component for Elxis 4.1
The component will feature multilingual content. Should i use the built-in table elx_translations for storing/retrieving the translation or create new tables ?
Whats the correct way of utilizing Elxis cms when building a custom component with multilingualism?
Thank you
-
You can use the standard table elx_translations. Just set the "category" column to the name of your component, for example "com_something". This way you distinguish the translations for your component with the others. The management of the translations if you use the built-in Elxis Forms library is automatic, so you have nothing special to do. Here is an example of a multilingual input text field:
$trdata = array('category' => 'com_something', 'element' => 'title', 'elid' => intval($row->id));
$form->addMLText('title', $trdata, $row->title, $eLang->get('TITLE'), array('required' => 1, 'size' => 50, 'maxlength' => 180));
As for the second question I don't understand what you mean by saying "utilizing Elxis cms". Your component is already inside Elxis cms, you don't have to initialize Elxis or do anything special. You can directly use Elxis libraries. Begin building the file something.php and create a router for the frontend and the backend sections. The router should check the URL segments and route the user request to the proper controller. If you have any question go ahead. We are here to help!
-
Thank you datahell for the reply. ill use elx_translations table for the component's multilingual translations
-
Another question
1) Does Elxis CMS allows Users to login via E-mail instead of username? or this is something thats needs a custom login form
2) My custom component will have two distinct user roles, with their own front-end panel. So shall i register the user on the default "elx_users" table and then add component specific fields in a "customComp_usersinfo" table and link those tables with the "uid" field? Its this a fair way to do this? i would like to reuse as much built-in functionality as possible
thank you in advance
-
Answer to question 1
Elxis has an extension type named "Authentication method". Built-in authentication methods are: Elxis (standard), LDAP, Gmail, OpenId and Twitter. You can build your own custom authentication method and install it just like any other Elxis extension type. Authentication methods are located here: components/com_user/auth/
For security reasons, users login with any other authentication method than "Elxis" are handled as "External Users" (gid = 6, access level =1) with limited permissions. Standard Elxis login users are on group 5 with access level = 2. Administrators have full permissions (level = 100).
The standard Elxis authentication method requires username/password. You can create a copy of it, name it whatever you like and make it accept email/password instead. After the user submits the form you should query the database and convert the email to the corresponding username and then try login with username/password. This why you will be able to login as a standard Elxis user and not an external one.
Answer to question 2
Standard Elxis users should be listed in table elx_users. Elxis ACL can help you assign permissions to any user, even external ones and guests, and also to any element. If your users have special roles on your component I suggest you do the following.
Create standard Elxis users and assign them special privileges to your component. For example IOS Reservations Hotels has "hoteliers". Each hotelier is an Elxis user (gid = 5, access level =2) but with special privileges on IOSR (like access on Hoteliers control panel). To make someone a hotelier pick a user and say "I make you a hotelier". If you break this assignment the user account will still exist but he will loose his privileges on IOSR. So this is the proper way I think for your case too.
Here is a part of the hoteliers table in IOSR.
hoid int(11) NOT NULL auto_increment, hotelier id
uid int(11) NOT NULL default 0, assigned user to this hotelier account
active tinyint(1) NOT NULL default 0, is he an active hotelier?
permcp tinyint(1) unsigned NOT NULL default 1, can access control panel?
permhotels tinyint(1) unsigned NOT NULL default 1, can manage hotels?
permrooms tinyint(1) unsigned NOT NULL default 1, can manage rooms?
etc...
IOSR also sets automatically user based permission to Hoteliers for accessing component's eTranslator API (components > com_etranslator > api) - Yes, Elxis has a hidden translations API :-) Else they will not be allowed to edit multilingual elements in forms.
You can alternatively build custom user groups with the same level as standard users (level = 2) and use Elxis ACL to check access.
Example.
Create a user group with gid = 8 and level =2
Assign all your special users there.
Then set permission to an element "Special Control Panel" (specialcp)
Category = com_something
Element = specialcp
Identity = 0
Action = view
Minimum level = -1
gid = 8
uid = 0
ACL value = 1
Now, users belonging to group 8 will be able to View the Special Control Panel. No one else will be, even the administrators (as you have set a group specific access rule).
You check the access like this:
$elxis = eFactory::getElxis();
if ($elxis>acl()->check('com_something', 'specialcp', 'view') > 0) {
//provide access
}
You can set ACL rules with the minimum level, or the group id, or even the user id (provide access only to specific users). ACL rules work combined. A user might get access to an element cause of his group and to an other element cause of his minimum access level. So it is safe to create custom groups with the same access level. You can play with it in your Elxis installation. Change, for example, a module's access to something custom and you will see how it works.
To add/edit an ACL rule in your custom component you have nothing to do, just open a popup window to this URL:
http://www.example.com/estia/inner.php/user/acl/edit.html?id=X (set 0 for new rules).
Component User will do the rest.
-
Thank you datahell for your excellent feedback!
3) Lets say component is "com_test" , then accessing the component would be domain.com/test/
I have set the routing of home page (domain.com) to the component "test:/" , however when i want to access some component's functions like /test/action1/ via domain.com/action1/ Elxis interprets that "action1" is a category and returns a -CCON-0005 NOT FOUND error.
How can i let Elxis now that domain.com/action1 , should look under the com_test component ?
Thanks
-
No, this is just a frontpage option. In your links you must always use test/...
Also always write links as elxis uris, never hardcoded.
wrong:
test/sample/page.html
correct:
test:sample/page.html