Using a component A within component B

47 views
Skip to first unread message

Adam Rifat

unread,
Aug 8, 2012, 10:13:41 AM8/8/12
to joomla-de...@googlegroups.com
Hi All,

Is it possible to use the views/layouts etc of one component within another? 

For example, I have built a screen to show a list of special offers associated to a particular record. This is done in component A that will only be available to a non super admin group. 

I can see that I might need to develop a separate component B to allow admins to view and administer *all* special offers regardless of who created them or to which item they are assigned to.

Is it possible to 'mix and match' or use a view from one component within another (similar to com_content? If not perhaps it is best I rethink my approach and just have all users use a separate 'special offers' component and show only the items they are assigned.

Any ideas?

Ad

Matt Thomas

unread,
Aug 8, 2012, 12:00:37 PM8/8/12
to joomla-de...@googlegroups.com
Hi Adam,

I'm not exactly a seasoned developer, but it sounds like implementing ACL rules within your component might allow you to use one view for everything. You might take a look at http://docs.joomla.org/Adding_ACL_rules_to_your_component and see if that helps.

Best,

Matt Thomas
Founder betweenbrain
Phone: 203.632.9322
Twitter: @betweenbrain




--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To view this discussion on the web, visit https://groups.google.com/d/msg/joomla-dev-general/-/BCzY8dl_XQ8J.
To post to this group, send an email to joomla-de...@googlegroups.com.
To unsubscribe from this group, send email to joomla-dev-gene...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/joomla-dev-general?hl=en-GB.

Mushr00m

unread,
Aug 11, 2012, 8:02:14 PM8/11/12
to joomla-de...@googlegroups.com
Like Betweenbrain says the ACL system is a lot more easy than having 2 component for that purpose...

Ove

unread,
Aug 12, 2012, 12:44:13 PM8/12/12
to joomla-de...@googlegroups.com, Mushr00m
Adam, is it a backend only issue or also frontend? There is a small difference for the Joomla Cms core components. Add, change and delete items are handled by the component Acl. If you need "groups" the use of the Joomla categories and it's Acl on itemlevel might solve this. I suppose you have your items in a db table where you can add a category-id field. If you need Acl on item level it gets more complex.

If your users need to view items in the backend that they are not allowed to change  (this is the difference) you should use the Accesslevels and create a new view to show the item. I've made some experimental use of the same form (=view) to avoid double maintenance but this means a couple of more or less complex overrides

Ove
--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To view this discussion on the web, visit https://groups.google.com/d/msg/joomla-dev-general/-/BI79imNnJM4J.

Adam Rifat

unread,
Aug 14, 2012, 5:46:48 AM8/14/12
to Ove, joomla-de...@googlegroups.com, Mushr00m

Ove and Betweenbrain, thanks for your thoughts. Always good to get another perspective.

 

Let me elaborate a little... 

 

I'm developing a property management component (backend only)  where a user can manage aspects of their property. That is, the description, images,  availability, prices and special offers etc. I am porting a legacy system into Joomla. 

 

I have it setup so that the user group 'property owner' can access the component and only sees a list (JModelList) of properties that they own. A second 'admin' user group can also access the same component but this time they would see a list of all properties on the system. Initially, I thought about doing this with the ACL and the core.editown ACL rule but that wasn't correct so I simply only select those properties the user owns if they are not in an admin group as follows:

 

// Check the user group this user belongs to.

// 8 is super user admin group. 
if (!in_array(8, $groups))
{
  $query->where('created_by='.$userId);
}
 

This works fine and limits one user group to only edit the properties that they own. The ACL complements this well enough as I can control which group can delete or publish items through the core ACL options.

 

With the special offers I have set up a list view of all the special offers a user 'owns' but currently this is a view within my property management component. After consideration I think what I will do (as you both suggested) is to make a separate 'special offers' component and simply link to it via the property manager component (or perhaps have a modal for it). That way I can make use of the ACL permissions for publish, delete etc and possibly add custom item specific ACL rules, but am awaiting the wiki updates to truly understand how to do that... ;-)

 

Anyway, hope that makes sense and wasn't too boring... :-)

  

Thanks again,

 

Adam

Reply all
Reply to author
Forward
0 new messages