Hi all! I'm a new in jamroom module development and have some questions - could you help me please? I don't understand - how I can pass variables from controller (which located in root directory) to my .tpl file (located in /themes/myTheme/myModule.tpl )?
I use now only one way to do it - create a new smarty function for my component and use it in .tpl file to display some info from database. But I think - it's not a good way to do so - we need to pass variables from controller...
PS
And could you explain me - does JamRoom based on MVC pattern or not? (I see controller and view... but don't see a model)
you can structure any way you want. what part is MODEL? schema.php maybe Im not up with all the technical terms.
For me I use the main file in the root directory to establish zones that exist and put a switch at the bottom to redirect to sections.
I keep all of my sections in a file with another switch to functions related to the sections, and have a class for each section.
From the class the individual methods/functions (depending on what word you like) go and get all the data and pass that out to the templates like this:
Code
public function view() {
global $_post, $jamroom, $_user;
$interesting_id = (int) ($_post['interesting_id'] > 0) ? $_post['interesting_id'] : 0;
if($interesting_id == 0){
jmLogger(0, 'CRI', 'apMymodule: view was opened without an interesting id.');
print "error: there was no interesting id.";
return;
}
//-----------------
//interesting data
//-----------------
$sql = "SELECT *
FROM jamroom_Somewhere_interesting
WHERE interesting_id = {$interesting_id} ";
htmlShowTemplate('apMymodule, 'index.tpl', $data); // the index.tpl file in this case will be located in /modules/apMymodule/templates/index.tpl if you want to use the skin, then use 'skin' instead of the module name.
}
but it isn't connected with my module cotriller (site.com/jrAlbumsList.php) how I can connect them? I mean - to provide logic in contoller and show data in profile tab.
The "jr" part of that means the function was created by the Jamroom team. for your functions pick 2 letter prefix.
I use "ap" for my company apicos.com. so all my modules are
apGraphs
apAffiliate
apSomething
etc....
If you start naming functions you created as jr...... it will get confusing for others looking at your code because they wont be able to find documentation. so maybe "dzAlbumsList" or "diAlbumsList" or whatever you like.
other prefixes ive seen around are "n8" "pa" "qik" off the top of my head, im sure there are others.