I was trying to write a mod to display my video collection, which is in a MySQL db, and thought I should give it more options to appeal to a wider community. In working on the action.defaultadmin.php I used the company directory mod as a guideline, but I'm kinda stuck and I'm hoping that someone could point me in the right direction to code this properly.
As it stands now, the format of the admin page is wrong, with the tabs appearing below their content. I'm trying to get 3 tabs, the main one, where the data is listed, and two template edit tabs (summary and detail).
Also, how do I paginate the results? The database has 2000 entries and I would like to show only 20 at a time on the admin data list.
Here's the code from action.defaultadmin.php
Code: Select all
<?php
if (!isset($gCms)) exit;
if (! $this->CheckAccess())
{
return $this->DisplayErrorPage($id, $params, $returnid,$this->Lang('accessdenied'));
}
echo $this->StartTabContent();
if ($this->CheckPermission('Add Video'))
{
echo $this->StartTab('videocollection', $params);
$entryarray = array();
$query = "SELECT * FROM ".cms_db_prefix()."module_video_collector ORDER BY movie_title";
$dbresult = $db->Execute($query);
$rowclass = 'row1';
while ($dbresult && $row = $dbresult->FetchRow())
{
$onerow = new stdClass();
$onerow->id = $row['id'];
$onerow->movie_title = $row['movie_title'];
$onerow->movie_year = $row['movie_year'];
$onerow->IMDB_no = $row['IMDB_no'];
$onerow->album_no = $row['album_no'];
$onerow->page_no = $row['page_no'];
$onerow->no_discs = $row['no_discs'];
$onerow->scr = $row['scr'];
$onerow->editlink = $this->CreateLink($id, 'editmovie', $returnid, $gCms->variables['admintheme']->DisplayImage('icons/system/edit.gif', $this->Lang('edit'),'','','systemicon'), array('movieid'=>$row['id']));
$onerow->deletelink = $this->CreateLink($id, 'deletemovie', $returnid, $gCms->variables['admintheme']->DisplayImage('icons/system/delete.gif', $this->Lang('delete'),'','','systemicon'), array('movieid'=>$row['id']), $this->Lang('areyousure'));
$entryarray[] = $onerow;
($rowclass=="row1"?$rowclass="row2":$rowclass="row1");
}
$this->smarty->assign_by_ref('items', $entryarray);
$this->smarty->assign('itemcount', count($entryarray));
$this->smarty->assign('addlink', $this->CreateLink($id, 'addmovie', $returnid, $gCms->variables['admintheme']->DisplayImage('icons/system/newfolder.gif', $this->Lang('addmovie'),'','','systemicon'), array(), '', false, false, '') .' '. $this->CreateLink($id, 'addmovie', $returnid, $this->Lang('addmovie'), array(), '', false, false, 'class="pageoptions"'));
$this->smarty->assign('exportcsv', $this->CreateLink($id, 'exportcsv', $returnid, $this->Lang('exportcsv')));
$this->smarty->assign('importcsv', $this->CreateLink($id, 'importcsv', $returnid, $this->Lang('importcsv')));
$this->smarty->assign('movietext', $this->Lang('movie'));
#Display template
echo $this->ProcessTemplate('movielist.tpl');
echo $this->EndTab();
echo $this->StartTab('summarytemplate', $params);
echo $this->CreateFormStart($id, 'updatesummarytemplate');
echo '<p>'.$this->CreateTextArea(false, $id, $this->GetTemplate('displaysummary'), 'templatecontent', 'pagebigtextarea').'</p>';
echo $this->CreateInputSubmit($id, 'submitbutton', $this->Lang('submit'));
echo $this->CreateInputSubmit($id, 'defaultsbutton', $this->Lang('sysdefaults'), '', '', $this->Lang('restoretodefaultsmsg'));
echo $this->CreateFormEnd();
echo $this->EndTab();
echo $this->StartTab('detailtemplate', $params);
echo $this->CreateFormStart($id, 'updatedetailtemplate');
echo '<p>'.$this->CreateTextArea(false, $id, $this->GetTemplate('displaydetail'), 'templatecontent2', 'pagebigtextarea').'</p>';
echo $this->CreateInputSubmit($id, 'rsssubmitbutton', $this->Lang('submit'));
echo $this->CreateInputSubmit($id, 'defaultsbutton', $this->Lang('sysdefaults'), '', '', $this->Lang('restoretodefaultsmsg'));
echo $this->CreateFormEnd();
echo $this->EndTab();
}
echo $this->EndTabContent();
$this->smarty->assign('tab_headers',$this->StartTabHeaders().
$this->SetTabHeader('videocollection',$this->Lang('title_videocollection')).
$this->SetTabHeader('summarytemplate',$this->Lang('title_summarytemplate')).
$this->SetTabHeader('detailtemplate',$this->Lang('title_detailtemplate')).
$this->EndTabHeaders().$this->StartTabContent());
$this->smarty->assign('end_tab',$this->EndTab());
$this->smarty->assign('start_videocollection_tab',$this->StartTab('videocollection'));
$this->smarty->assign('start_summarytemplate_tab',$this->StartTab('summarytemplate'));
$this->smarty->assign('start_detailtemplate_tab',$this->StartTab('detailtemplate'));
echo $this->ProcessTemplate('adminpanel.tpl');
?>
Nullig