Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1
  • 2

TOPIC: Table Categories -> Nested

Re: Table Categories -> Nested 26 Apr 2013 06:50 #7084

  • dieda1821
  • dieda1821's Avatar
  • Offline
  • Senior Member
  • Posts: 53
  • Thank you received: 2
  • Karma: 4
Hi,

By checking better, the method works, but the "path" column is not updated. When I save an element all the fields (lft, rgt, etc...) are updated correctly, but the "path" field remains empty...is this normal ?

Elena
The administrator has disabled public write access.

Re: Table Categories -> Nested 26 Apr 2013 14:13 #7085

  • dieda1821
  • dieda1821's Avatar
  • Offline
  • Senior Member
  • Posts: 53
  • Thank you received: 2
  • Karma: 4
Hi again,

No way to have the "addRoot" function working.

This is the query in my case:
$columns = array('id','el_ref','parent_id', 'lft', 'rgt','level','title','alias','access');
	
    	$db2 = JFactory::getDbo();
		$query_add = $db2->getQuery(true);
 
    	$values = array(1, $db2->quote('system'), 0, 0, 1, 0, $db2->quote('root'), $db2->quote('root'), 1);
		$query_add
    			->insert($db2->quoteName('#__manta_elements'))
    			->columns($db2->quoteName($columns))
    			/*->values("'0','0','1','0','{$db->quote('root')}','{$db->quote('root')}','1','{$db->quote('')}'");*/			
				->values(implode(',', $values));
	       		$db2->setQuery($query_add);			
				try {
          	 $apply = $db2->query_add();  // $db->execute(); for Joomla 3.0.
			} catch (Exception $e) {
   			// catch the error.
		    }

			$query_add->clear();

The query is correct, I checked it separately.

When I evaluate the existence of the root element inside the "prepareTable" function, I would like, in case of non-existence, to have the root node created before I save my element. Anyhow, either if call the addRoot function or if I directly insert it inside my if statement, I can't have the root node created.

I do not receive any error message, simply the first query is not executed and then the second one fails becaues the parent_id (which is the root id) is not correct (this is obvious, since the root element has not been created).

Can anyone suggest where I should call the root test and query so to have it executed before the element is saved? Clearly the "prepareTable" function is not the right place...

So far, the only workaround that I can think about is to create the root element via sql when the database is created. But I would like to know anyhow how I could have the addRoot function working.

Thanks for any possible suggestion.

Elena
The administrator has disabled public write access.
  • Page:
  • 1
  • 2
Time to create page: 0.090 seconds

Get Started