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

TOPIC:

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

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

Please Log in or Create an account to join the conversation.

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

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

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
  • 2
Time to create page: 0.078 seconds

Although I found this tool some time ago I just started learning experimenting and building this first component on Monday and now on Thursday afternoon it's already online. Although I already had a working version done with another tool this is much easier to build and at the end you have the freedom to own your own component. Once you know how to use Cook you will boost your productivity as the learning curve is really moderate compared to many other tools.
Giori (Forum)

Get Started