×
This forum has been locked. Please submit new Feature Requests on GitHub: github.com/Jensen-Technologies/component-creator-issues/issues
Nested Sets
Yonder Media
Nouveau membre
Posts: 7
il y a 9 ans 8 mois #666
par Yonder Media
Nested Sets a été créé par Yonder Media
Having used Component Creator quite extensively, one of the things I find myself having to make over and over again, are nested set models. For instance, Nested Sets are used in Joomla's native Category component, allowing n-tiered nesting of categories associated with other categories.
In the Table class, this requires changing it from JTable to JTableNested, and including code in the prepareTable function of the model class (an example is shown below:)
Additionally, then, this requires changes to the View classes and markup output, to correctly show entries as being nested within each other. For this, I've borrowed code from Joomla's Category Component to achieve this.
Whilst I can get this all to work, it would be a really cool feature to have this built-in to Component Creator!
In the Table class, this requires changing it from JTable to JTableNested, and including code in the prepareTable function of the model class (an example is shown below:)
protected function prepareTable($table)
{
jimport('joomla.filter.output');
$db = JFactory::getDbo();
// Specify where to insert the new node.
$parent = @$table->parent_id;
if (!empty($parent))
{
$table->setLocation($parent, 'last-child');
}
else
{
$rootId = $table->getRootId();
if ($rootId === false)
{
$db = JFactory::getDbo();
$sql = 'INSERT INTO #__yomo_ussd_article_category'
. ' SET parent_id = 0'
. ', lft = 0'
. ', rgt = 1'
. ', level = 0'
. ', title = '.$db->quote('root')
. ', alias = '.$db->quote('root')
. ', access = 1'
. ', path = '.$db->quote('')
;
$db->setQuery($sql);
$db->query();
$parent = $db->insertid();
$table->setLocation($parent, 'last-child');
}
else
{
$table->setLocation($rootId, 'last-child');
}
}
# Check that the node data is valid.
$table->check();
# Store the node in the database table.
$table->store();
}
Additionally, then, this requires changes to the View classes and markup output, to correctly show entries as being nested within each other. For this, I've borrowed code from Joomla's Category Component to achieve this.
Whilst I can get this all to work, it would be a really cool feature to have this built-in to Component Creator!
Connexion ou Créer un compte pour participer à la conversation.
RIP Graphics
Nouveau membre
Posts: 16
il y a 9 ans 8 mois #667
par RIP Graphics
Réponse de RIP Graphics sur le sujet Nested Sets
+1
Connexion ou Créer un compte pour participer à la conversation.
Pete
Membre junior
Posts: 27
il y a 9 ans 7 mois #700
par Pete
Réponse de Pete sur le sujet Nested Sets
+1
Connexion ou Créer un compte pour participer à la conversation.
Søren Beck Jensen
Administrateur
Posts: 81
il y a 9 ans 6 mois #771
par Søren Beck Jensen
Søren Beck Jensen
Founder, Component-Creator.com
Réponse de Søren Beck Jensen sur le sujet Nested Sets
Please note that this relates only to nested sets of custom tables. You can always use the Joomla Category field and create as many nested categories you would like.
Thanks to Brian Teeman for pointing this out.
Thanks to Brian Teeman for pointing this out.
Søren Beck Jensen
Founder, Component-Creator.com
Connexion ou Créer un compte pour participer à la conversation.
Ilya Protasov
Nouveau membre
Posts: 9
il y a 9 ans 4 mois #876
par Ilya Protasov
Réponse de Ilya Protasov sur le sujet Nested Sets
+1
Connexion ou Créer un compte pour participer à la conversation.
Jesper
Nouveau membre
Posts: 6
il y a 9 ans 4 mois #883
par Jesper
Réponse de Jesper sur le sujet Nested Sets
+1 as i sit and could use this right now for something i have to build
Connexion ou Créer un compte pour participer à la conversation.
Temps de génération de la page : 0.061 secondes