Method to use to get the uid

Discuss PivotX 2.0.x extensions here, and view extensions that are available for download.

Method to use to get the uid

Postby Khevor » Tue Aug 12, 2008 9:19 pm

I've tried just about everything I could think of but nothing seems to work. Now either I'm seriously doing something wrong, or the option isn't available, so this is my call for help. LOL

I'm writing an extension and I'm trying to get the UID for a given entry. I've tried $PIVOTX['db']->entry['code'] but that won't work (to test why it doesn't, I did a print_r($PIVOTX) and under db->entry, everything is blank -- having said that, all the info I could possibly want is located in the Smarty Object within $PIVOTX but I have no idea how to retrieve it).

I even tried [[ code ]] and [[ uid ]] in the templates. Nothing. I even tried to register an old snippet as a smarty object to see if I could use snippet_code but that just uses the $PIVOTX['db']->entry['code'] which doesn't work anyway so that was a wasted effort. I scanned through all the modules looking for anything I might be able to use but none of the functions do the one thing I need them to do. (I even went so far as to try putting &$smarty as a passed variable in the widget and then use $vars = $smarty->get_template_vars();, but that gave me a completely blank page.)

So that was yesterday's adventure.

On an unrelated side note:
Also, I noticed that you can't use the sql class in an extension without instantiating the class within it (for the purposes of creating tables and doing queries). Was that done on purpose? Just curious.
Khevor
 
Posts: 26
Joined: Sun Aug 03, 2008 2:37 am
Location: Ontario, Canada

Re: Method to use to get the uid

Postby Khevor » Wed Aug 13, 2008 12:23 am

It would appear that I needed a little more time and a clearer head. Turns out I was on the right track.

This is what ultimately worked.
Code: Select all
$vars = $PIVOTX['template']->get_template_vars();
$entry_uid = $vars['entry']['uid'];


My question about needing to reinstantiate the sql class still stands though. I'm curious about it because I want to make sure I'm not inadvertently screwing something up by doing it.
Khevor
 
Posts: 26
Joined: Sun Aug 03, 2008 2:37 am
Location: Ontario, Canada


Return to 2.x Extensions

Who is online

Users browsing this forum: No registered users and 1 guest

cron