YOOtheme Pro is here! The best WordPress and Joomla theme. Learn more

Avatar david.dahl asked

I am at wits end - How do I access the ZOO item_id in a form outside of ZOO? Is the Event Plug-in broken?

Hello,

I have lost what little hair I have left trying (for over seven hours) to figure this out.

I have a ZOO item (name of product) I would like to display inside a form (BreezingForm). While I can access the element data from within ZOO using the element id I cannot figure out how to access the element from outside of ZOO (inside the form). The stumbling block appears to be I cannot access the ZOO item_id outside of ZOO iteself.

Using the code found in the documentation:

// load ZOO config  
require_once(JPATH_ADMINISTRATOR.'/components/com_zoo/config.php');  

// Get ZOO App instance  
$zoo = App::getInstance('zoo');

does not allow me to access the ZOO information needed. The code which works (when hard coded in the full.php renderer) is:

<?php  
// load ZOO config  
require_once(JPATH_ADMINISTRATOR.'/components/com_zoo/config.php');  
// Get ZOO App instance  
$zoo = App::getInstance('zoo');  
$item = $this->app->table->item->get($item->id);  
$element_value = $item->getElement('2e3c9e69-1f9e-4647-8d13-4e88094d2790')->getElementData()->get('value');   
echo $element_value;   
?>

Unfortunately, this code brings up null errors when ported over to the form. After extensive testing I believe the $item variable is not coming through.

So, to sum up I have code that will work if placed directly inside ZOO but not if I have it embedded in a form on the same page. The ZOO Event Plug-in doesn't seem to work for me.

I really, really need this to work and cannot understand what I am doing wrong. Any help is greatly appreciated.

Thanks,

David

Update:

Ray,

Thank you for your guidance, it is (really) appreciated.

Upon reflection, I think I may be missing some fundamental understanding of how a zoo variable works. My intent is to display a ZOO item at the top of a page and then in a separate module at the bottom of the same page (outside of the ZOO application) show content from within the ZOO application above.

The stumbling block appears to be centered around the Item ID number.

While I am able to identify and display the necessary Item ID within the ZOO application (at the top of the page) I am unable to transfer/copy that Item ID into a module (outside of ZOO) at the bottom.

My previous code (which you helped with) was intended to pluck the Item ID needed from the ZOO application at the top for use (outside of ZOO) at the bottom. With your reply, I now realize that I was creating a new ZOO instance which returned the Boolean error and not the item ID from above.

So, the question has now morphed into:

‘How do I transfer/copy a ZOO Item ID number from the application to a module outside of the application on the same page?’

If useful I am happy to create a temporary website with a ZOO application to more clearly show my intent. Please let me know.

Thanks!

Sincerely,

David

  • Joomla
  • ZOO
  • General Question

Edited

3 Answers

0

Avatar ray.lawlor answered

Change:

$item = $this->app->table->item->get($item->id); 

to:

$item = $zoo->table->item->get($item->id); 

See, on line 4 where you've instantiated ZOO with:

$zoo = App::getInstance('zoo'); 

This puts the ZOO framework inside the $zoo object variable. From there you use $zoo to access zoo features.

Then you try to use "$this"... but if you're outside ZOO then $this won't work.

Hope that helps!

Ray
http://www.zoomodsplus.com/

Edited

0

Avatar david.dahl answered

Ray,

Thank you for your guidance, Unfortunately, when I make the change you suggest I now get an error:

0 - Call to a member function getElement() on boolean

I am by no means a expert in PHP and am hopeful you can help further.

Sincerely,

David

0

Avatar ray.lawlor answered

Sorry for the wait David... I wasn't alerted to your reply...

Ok it looks like "$item->id" has no value.

Because ... if you think about it... we're trying to get an item, with it's own id... before we even have the item!!! How can we have an "$item" object before we retrieve the item?? :)

So we need to get the ID into the "$zoo->table->item->get(ID); " function...

Where is this ID coming from in your script? Do you or your script know the id of the item you're trying to get?

If you don't know it... or your script doesn't know it, then we'll need to get via another way...

You could use this code:

$zoo->table->item->search(SEARCH_TERM); 

This is a real long shot... as it will return an array... even if it's a single item... from there, you'd have to pick aprt the array to get the item out.

Ray
Lead Developer, ZooModsPlus - http://www.zoomodsplus.com/

Edited

Know someone who can answer? Share a link to this question via email or twitter.