Watch
GitHub Core
Show your support for Zikula! Sign up at Github account and watch the Core project!
GitHub Modules
- mesteele101 responded to »ERR (3): E_USER_ERROR: Smarty error: [in pagesvar:pagesitem2en line XXX]…« 07:01 AM
- mazdev responded to »Pages 2.5.0 and updating - Page not found« 06:41 AM
- ehdwma created topic »Hide "Register new account" and change template to 3 col« 06:27 AM
- mesteele101 responded to »Zikula 1.3.3 - Selecting a category in Pages not working« 01:29 AM
- mdee created topic »How to implement returnpage ?« 01:00 AM
- nestormateo responded to »Fillters in Clip« 24. May
- damon responded to »Can the Updated Version Check be Turned Off (Z 1.3)« 24. May
Zikula Blog
- Anatomy of Open Source Projects on Mar 07
- Continuous Review on Mar 01
- Not Invented Here on Feb 24
- How to Contribute Your Code at Github on Jan 13
- 10 Steps to Coding-Nirvana: Tips for Successful Module Writing on Nov 12
- Submitting Bug Report Tickets That Get Results on Aug 17
- Cozi Tricks #1: Syntax Highlighting on Aug 07
Login
Grabbing tables from other modules
-
**unknown user**
- Rank: Registered User
- Registered: Mar 16, 2002
- Last visit: Apr 01, 2005
- Posts: 8
I need to use info stored in tables that are not defined in the module I am editing, but whenever I try to load the API from a different module I get an error. I am new to postnuke and don't know how to use information from other modules. Am I missing something simple? Thanks. -
- Rank: Developer
- Registered: Dec 31, 1969
- Last visit: Jun 01, 2010
- Posts: 6859
It's best to use the module API to load data from said module, it's easier. What is the code you're using.
Also moved this to the right forum.
--
Home Page | Find on Facebook | Follow on Twitter
-
**unknown user**
- Rank: Registered User
- Registered: Mar 16, 2002
- Last visit: Apr 01, 2005
- Posts: 8
function foodmanagement_admin_view() {
$dbconn =& pnDBGetConn(true);
$pntable =& pnDBGetTables();
// Get parameters from whatever input we need. All arguments to this
// function should be obtained from pnVarCleanFromInput(), getting them
// from other places such as the environment is not allowed, as that makes
// assumptions that will not hold in future versions of PostNuke
$startnum = pnVarCleanFromInput('startnum');
// Create output object - this object will store all of our output so that
// we can return it easily when required
$output =& new pnHTML();
// if (!pnSecAuthAction(0, 'FoodManagement::', '::', ACCESS_EDIT)) {
// $output->Text(_SKCONFIGNOAUTH);
// return $output->GetOutput();
// }
// Add menu to output - it helps if all of the module pages have a standard
// menu at their head to aid in navigation
$output->SetInputMode(_PNH_VERBATIMINPUT);
$output->Text(foodmanagement_adminmenu());
$output->SetInputMode(_PNH_PARSEINPUT);
// Title - putting a title ad the head of each page reminds the user what
// they are doing
$output->Title(_VIEWSKCONFIG);
// Load API. Note that this is loading the user API, that is because the
// user API contains the function to obtain item information which is the
// first thing that we need to do. If the API fails to load an appropriate
// error message is posted and the function returns
if (!pnModAPILoad('FoodManagement', 'user')) {
$output->Text(_LOADFAILED);
return $output->GetOutput();
}
// The user API function is called. This takes the number of items
// required and the first number in the list of all items, which we
// obtained from the input and gets us the information on the appropriate
// items.
$items = pnModAPIFunc('SKConfig',
'user',
'getall');
foreach ($items as $item){
$output->Text($item['date']);
}
return $output->GetOutput();
}
I need to use the SKConfig module's tables but this isn't letting me do it, and if I try to load SKConfig's API above it errors on me. I have all of this wrong conceptually, but I can't figure it out...I know the getall function works correctly, but it isn't returning with anything...in fact, if i change the function name to anything else it still runs...it just doesn't return anything, leading me to believe that it isn't even getting that far to check whether or not it is a valid function.
I don't know how else to get the table info from SKConfig. Thanks. -
**unknown user**
- Rank: Softmore
- Registered: Mar 16, 2002
- Last visit: Oct 21, 2009
- Posts: 379
If calling the API doesn't work (and I've had problems trying to use the UpDownload program as I want, 'cause it's not API compliant) and you need to get information from that table, you need to make sure you copy the relevant table definition code from the pntables file. Then you should be able to access it and display it as you would your own tables.
And as Mark would say, the pnHTML code is deprecated, so you might want to look at pnRender. :D -
- Rank: Team Member
- Registered: Mar 18, 2002
- Last visit: Oct 21, 2009
- Posts: 6606
jediping
Iyou need to make sure you copy the relevant table
No.... If a module has it's own pntables file then this can be loaded with pnModDBInfoLoad('<modname>');
-Mark
--
Visit My homepage and Zikula themes.</modname> -
- Rank: Team Member
- Registered: Mar 18, 2002
- Last visit: Oct 21, 2009
- Posts: 6606
jediping
Oooooo, really????? Yay! I didn't know about that one. Wooot! I'll mod my code as soon as I get to work. :)
You don't see it that much since the core loads the table information (by calling this very API) for API compliant modules. However it's useful for non
API compliant module, search plugins, blocks etc.
It is documented in the API reference though....
-Mark
--
Visit My homepage and Zikula themes. -
- Rank: Expert
- Registered: Dec 02, 2002
- Last visit: Apr 30, 2010
- Posts: 1474
Mark,
Do you know of any modules that incorporate the pnModDBInfoLoad('<modname>'); function ?
-Lobos
--
-Lobos
Professional PHP Framework Services: Concept, Development and Deployment</modname> -
- Rank: Team Member
- Registered: Mar 18, 2002
- Last visit: Oct 21, 2009
- Posts: 6606
Lobos,
Not off the top of my head since pnModAPILoad and pnModLoad call pnModDBInfoLoad intermally so, in general, it's not required. Where you will need it is
a) in a search plugin for a module with it's own pntables file
b) in a block which contains direct SQL queries rather than calls to module API's
The only place I can think of where it's used in the ezcomments block.
-Mark
--
Visit My homepage and Zikula themes. -
**unknown user**
- Rank: Softmore
- Registered: Mar 16, 2002
- Last visit: Oct 21, 2009
- Posts: 379
So... to make sure, I can just use this anywhere in a module, not just on the pntables page? Haven't had a chance to check it out, and might not, since I have to switch servers, which means a lot of annoying downloading, but I'll be giving it a go once I have the time. -
**unknown user**
- Rank: Registered User
- Registered: Mar 16, 2002
- Last visit: Apr 01, 2005
- Posts: 8
I just want to make sure that I get everything straight here...(sorry)
1) my call to pnModAPIFunc('SKConfig', 'user', 'getall'); should not work because that function is in a different module and that is not allowed
2) instead, i need to call pnModDBInfoLoad('SKConfig');, but then how do I use this?
Thanks again. -
- Rank: Team Member
- Registered: Mar 18, 2002
- Last visit: Oct 21, 2009
- Posts: 6606
@jediping - take a look at the EZComments block I refernced lobos too. It shows how you'd use it. Basically you call pnModDBInfoLoad before you call pnDBGetTables. The order isn't 100% necessary since we used a reference to the pntables array but it makes more sense this away
@fritzd - No - you can (and should where necessary) call other module API's. As long as you make sure you load the correct API first via pnModAPILoad (.760 won't need this as API's will autoload on demand).
-Mark
--
Visit My homepage and Zikula themes. -
**unknown user**
- Rank: Softmore
- Registered: Mar 16, 2002
- Last visit: Oct 21, 2009
- Posts: 379
- Moderated by:
- Support
Users on-line
- 0 users
This list is based on users active over the last 60 minutes.
