Welcome, Guest
Username: Password: Remember me

TOPIC: [SOLVED] Joomla categories

[SOLVED] Joomla categories 11 Oct 2011 10:49 #189

Hi!
I want to know if is possible to use the joomla categories or do you have a table of categories?
tnx
Last Edit: 15 Oct 2011 16:28 by admin.
The administrator has disabled public write access.

Re: Joomla categories 11 Oct 2011 13:33 #190

  • admin
  • admin's Avatar
  • Online
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
No, it is not possible.
Coding is now a piece of cake
The administrator has disabled public write access.

Re: Joomla categories 11 Oct 2011 16:34 #195

ok thanks
The administrator has disabled public write access.

Re: Joomla categories 12 Oct 2011 04:58 #206

  • griiettner
  • griiettner's Avatar
  • Offline
  • Senior Member
  • Posts: 73
  • Thank you received: 12
  • Karma: 8
Actually.. it is...

It will give you a little extra work, but at the end will function correctly...

I would do this...

1 - Create a table called 'category' and would make it exactly clone of com_category table (Joomla's default category)

2 - Create the component as you normally would... with all the foreign keys, connecting categories to items and vice-versa.

3 - Once you are satisfied creating the component, build by normal process and install it to your Joomla.

4 - Go to the models and just rename the category table, so instead to save to your Component category, if would save to the Joomla's com_category table... example

The original Query on model would be something like this
function _buildQuery_ticket()
	{

			$query = 'SELECT a.*'
					.	' , _category_.title AS `_category_title`'
					. 	$this->_buildQuerySelect()

					.	' FROM `#__compname_item` AS a'
					.	' LEFT JOIN `#__compname_categories` AS _category_ ON _category_.id = a.category_id'
					. 	$this->_buildQueryJoin()

					. 	$this->_buildQueryWhere()

					.	'';
		return $query;
	}

So, you have to change for something like this
function _buildQuery_ticket()
	{

			$query = 'SELECT a.*'
					.	' , _category_.title AS `_category_title`'
					. 	$this->_buildQuerySelect()

					.	' FROM `#__compname_item` AS a'
					.	' LEFT JOIN `#__categories` AS _category_ ON _category_.id = a.category_id'
					. 	$this->_buildQueryJoin()

					. 	$this->_buildQueryWhere()

					.	'';
		return $query;
	}

Pay attention that the change was very small... I just renamed the LEFT JOIN `#__compname_categories` to `#__categories`... by this way, I stoped to use the component's categories table, to use Joomla's default categories table.

Hope you get the idea...

PS: Just remember that categories table, may be instantiated in another files on component, such as table folder, controllers and view... Simply rename as I suggested and everything will work fine... After you renamed all, you can drop the table you created and let the component use the default Joomla's table
Paulo Griiettner
Last Edit: 12 Oct 2011 04:59 by griiettner.
The administrator has disabled public write access.
The following user(s) said Thank You: urbanspaceman

Re: Joomla categories 12 Oct 2011 06:35 #208

many tnx, grriettner maybe this solve my problem
The administrator has disabled public write access.

Re: Joomla categories 12 Oct 2011 06:39 #209

  • griiettner
  • griiettner's Avatar
  • Offline
  • Senior Member
  • Posts: 73
  • Thank you received: 12
  • Karma: 8
Let us know if this worked for you, so people that want to do the same thing, would find this topic useful...
Paulo Griiettner
The administrator has disabled public write access.

Re: Joomla categories 13 Oct 2011 16:47 #220

  • admin
  • admin's Avatar
  • Online
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
I think this is not a good idea. What you propose is called a "database hack".

In some case it works, but you REALLY need to know what you do.

In particular on Joomla 1.6 category table, you may destroy the tree structure (hierarchy parenting) because some specials fields as 'lft', 'rgt', and 'level' will be broken.


If you do this to hack a Cook generated model, some functions will not be anymore supported. FK Integrityes for exemple.
Coding is now a piece of cake
The administrator has disabled public write access.

Re: Joomla categories 13 Oct 2011 18:26 #228

  • griiettner
  • griiettner's Avatar
  • Offline
  • Senior Member
  • Posts: 73
  • Thank you received: 12
  • Karma: 8
Admin...

You are right about the 1.7 version... the 'lft' and 'rgt' can be a problem for those that does not know how to use it... I would not have problem configuring that, but I'm not sure about others.

About the FK Integrity, it is just of a matter to generate the table and disable this on cook when creating the Foreign Key connection...

Any way... I posted just an Idea... but of course, this would require a more advance Joomla programmer that know exactly what he/she is doing.
Paulo Griiettner
The administrator has disabled public write access.

Re: Joomla categories 13 Oct 2011 18:33 #230

  • admin
  • admin's Avatar
  • Online
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
I do exactly the solution you described, when I use for my personal needs. It fits. But it is not a ready-to-use solution.

This was just the meaning of my comment.

For read only operations, there is no problem.
Coding is now a piece of cake
The administrator has disabled public write access.

Re: Joomla categories 25 Nov 2011 23:24 #623

  • Presto
  • Presto's Avatar
  • Offline
  • New Member
  • Posts: 5
  • Thank you received: 1
  • Karma: 0
It would be great to get this on the development road map, to use the default Joomla category manager. Why reinvent the wheel, when we can use what's already available out of the Joomla box ;) This would also cut down on the development time not having to create everything that goes along with managing categories.
The administrator has disabled public write access.

Re: Joomla categories 29 Nov 2011 12:48 #637

  • admin
  • admin's Avatar
  • Online
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
In facts, I understand.

But it is an intentional choice for many reasons.
- FK integrities should be much more complicated (creation of plugin)
- It is more comfortable to do not mix the database objects. Your component is contained only in the component tables (except for foreign object such as 'users')
- We are preparing a Nested table system wich will do exactly the same than categories, in more light, and even more extended possibilities.
- Our Nested system will be available in 1.5
- Templating of the categories is global, so it is a problem for particular uses

So. This functionality of categories integration is not a priority for the moment and if we include it, it will disallow the FK integrities (item cascad operations on category delete)
Coding is now a piece of cake
The administrator has disabled public write access.

Re: Joomla categories 23 Mar 2012 15:45 #1718

  • griiettner
  • griiettner's Avatar
  • Offline
  • Senior Member
  • Posts: 73
  • Thank you received: 12
  • Karma: 8
Jocelyn,

I know you already gave your explanations about this subject, but is there any chance to make integration of com_categories to cook developed components?

Would be great to have this feature in the same way you have for users, where it shows in the diagram the com_user tables and its connections with other tables...
Paulo Griiettner
The administrator has disabled public write access.
Time to create page: 0.116 seconds

Get Started