Hi there,
I’m trying to adjust the admin menu. I’m removing tabs so I decided to change menu.xml directly, without a modul. I know the risks.
I changed the the part below ‘Administer Products’ and replaced ‘Products’ with two other points, a picture of the german menu is attached below.
My changed menu.xml in parts:
<MAINMENU id="mxmanageprod">
<SUBMENU id="mxmanagepaper" cl="article" list="oxpr_magazine_list">
<TAB id="tbcl_zschrift_main" cl="article_main" />
<TAB id="tbcl_zschrift_extend" cl="article_extend" />
<TAB id="tbcl_zschrift_pictures" cl="article_pictures" />
<TAB id="tbcl_zschrift_seo" cl="article_seo" />
<BTN id="article_new" />
<BTN id="article_preview" />
</SUBMENU>
<SUBMENU id="mxmanagegift" cl="article" list="oxpr_bonus_list">
<TAB id="tbcl_zugabe_main" cl="article_main" />
<TAB id="tbcl_zugabe_extend" cl="article_extend" />
<TAB id="tbcl_zugabe_pictures" cl="article_pictures" />
<TAB id="tbcl_zugabe_seo" cl="article_seo" />
<BTN id="article_new" />
<BTN id="article_preview" />
</SUBMENU>
....
<SUBMENU id="mxarticles" cl="article" list="article_list">
<TAB id="tbclarticle_main" cl="article_main" />
<TAB id="tbclarticle_extend" cl="article_extend" />
<TAB id="tbclarticle_stock" cl="article_stock" />
<TAB id="tbclarticle_attribute" cl="article_attribute" />
<TAB id="tbclarticle_crossselling" cl="article_crossselling"/>
<TAB id="tbclarticle_variant" cl="article_variant"/>
<TAB id="tbclarticle_pictures" cl="article_pictures" />
<TAB id="tbclarticle_files" cl="article_files" />
<TAB id="tbclarticle_review" cl="article_review"/>
<TAB id="tbclarticle_overview" cl="article_overview" />
<TAB id="tbclarticle_seo" cl="article_seo" />
<BTN id="article_new" />
<BTN id="article_preview" />
</SUBMENU>
</MAINMENU>
I build two module oxpr_magazine_list and oxpr_bonus_list to change the selected article-list. The main-change in comparison to article_list is, that the sql for selecting the atricles is another one.
My code for oxpr_magazine_list in parts:
class oxpr_magazine_list extends oxAdminList
{
/**
* Name of chosen object class (default null).
*
* @var string
*/
protected $_sListClass = 'oxarticle';
/**
* Type of list.
*
* @var string
*/
# protected $_sListType = 'oxarticlelist';
protected $_sListType = 'oxarticlelist';
/**
* Collects articles base data and passes them according to filtering rules,
* returns name of template file "article_list.tpl".
*
* @return string
*/
public function render()
{
$myConfig = $this->getConfig();
$sPwrSearchFld = oxConfig::getParameter( "pwrsearchfld" );
$sPwrSearchFld = $sPwrSearchFld ? strtolower( $sPwrSearchFld ) : "oxtitle";
$oArticle = null;
$oList = $this->getItemList();
if ( $oList) {
foreach ( $oList as $key => $oArticle ) {
$sFieldName = "oxarticles__{$sPwrSearchFld}";
// formatting view
if ( !$myConfig->getConfigParam( 'blSkipFormatConversion' ) ) {
if ( $oArticle->$sFieldName->fldtype == "datetime" )
oxRegistry::get("oxUtilsDate")->convertDBDateTime( $oArticle->$sFieldName );
elseif ( $oArticle->$sFieldName->fldtype == "timestamp" )
oxRegistry::get("oxUtilsDate")->convertDBTimestamp( $oArticle->$sFieldName );
elseif ( $oArticle->$sFieldName->fldtype == "date" )
oxRegistry::get("oxUtilsDate")->convertDBDate( $oArticle->$sFieldName );
}
$oArticle->pwrsearchval = $oArticle->$sFieldName->value;
$oList[$key] = $oArticle;
}
}
parent::render();
// load fields
if ( !$oArticle && $oList ) {
$oArticle = $oList->getBaseObject();
}
$this->_aViewData["pwrsearchfields"] = $oArticle ? $this->getSearchFields() : null;
$this->_aViewData["pwrsearchfld"] = strtoupper( $sPwrSearchFld );
$aFilter = $this->getListFilter();
if ( isset( $aFilter["oxarticles"][$sPwrSearchFld] ) ) {
$this->_aViewData["pwrsearchinput"] = $aFilter["oxarticles"][$sPwrSearchFld];
}
$sType = '';
$sValue = '';
$sArtCat= oxConfig::getParameter( "art_category" );
if ( $sArtCat && strstr( $sArtCat, "@@" ) !== false ) {
list( $sType, $sValue ) = explode( "@@", $sArtCat );
}
$this->_aViewData["art_category"] = $sArtCat;
// parent categorie tree
$this->_aViewData["cattree"] = $this->getCategoryList($sType, $sValue);
// manufacturer list
$this->_aViewData["mnftree"] = $this->getManufacturerlist($sType, $sValue);
// vendor list
$this->_aViewData["vndtree"] = $this->getVendorList($sType, $sValue);
return "article_list.tpl";
}
......
/**
* Builds and returns SQL query string.
*
* @param object $oListObject list main object
*
* @return string
*/
protected function _buildSelectString( $oListObject = null ) {
$sQ = parent::_buildSelectString( $oListObject );
if ( $sQ ) {
$sTable = getViewName( "oxarticles" );
$sType = false;
$sArtCat = oxConfig::getParameter( "art_category" );
if ( $sArtCat && strstr( $sArtCat, "@@" ) !== false ) {
list( $sType, $sValue ) = explode("@@", $sArtCat );
}
error_log("oxpr_magazine_list - 1| sQ:
$sQ
"); #TODO - delete
$sInsert = '';
$oStr = getStr();
switch ( $sType ) {
// add category
case 'cat':
$sO2CView = getViewName( "oxobject2category" );
$sInsert = " FROM $sTable left join $sO2CView on $sTable.oxid = $sO2CView.oxobjectid "
." JOIN pr_object2generic_attributes og ON $sTable.oxid = og.pr_obj2gen_attr_objectid "
." JOIN pr_generic_attribute ga ON og.pr_obj2gen_attr_gen_attr_id = ga.oxid "
."WHERE $sO2CView.oxcatnid = " . oxDb::getDb()->quote($sValue) . " AND " ;
# $sQ = $oStr->preg_replace( "/from\s+$sTable\s+where/i", $sInsert, $sQ);
break;
// add manufactor
case 'mnf':
$sInsert = " FROM $sTable "
." JOIN pr_object2generic_attributes og ON $sTable.oxid = og.pr_obj2gen_attr_objectid "
." JOIN pr_generic_attribute ga ON og.pr_obj2gen_attr_gen_attr_id = ga.oxid "
."WHERE ";
$sQ.= " and $sTable.oxmanufacturerid = ".oxDb::getDb()->quote($sValue) . " AND ";
break;
// add vendor
case 'vnd':
$sInsert = " FROM $sTable "
." JOIN pr_object2generic_attributes og ON $sTable.oxid = og.pr_obj2gen_attr_objectid "
." JOIN pr_generic_attribute ga ON og.pr_obj2gen_attr_gen_attr_id = ga.oxid "
."WHERE ";
$sQ.= " and $sTable.oxvendorid = ".oxDb::getDb()->quote($sValue) . " AND ";
break;
default:
$sInsert = " FROM $sTable "
." JOIN pr_object2generic_attributes og ON $sTable.oxid = og.pr_obj2gen_attr_objectid "
." JOIN pr_generic_attribute ga ON og.pr_obj2gen_attr_gen_attr_id = ga.oxid "
."WHERE ";
}
$sQ = $oStr->preg_replace( "/from\s+$sTable\s+where/i", $sInsert, $sQ);
$sQ .= " AND ga.pr_generic_attribute_name = 'pr_article_type' ";
$sQ .= " AND og.pr_obj2gen_attr_value = 'pr_zeitschrift' ";
error_log("oxpr_magazine_list | sInsert:
$sInsert
"); #TODO - delete
}
error_log("oxpr_magazine_list - 2| sQ:
$sQ
"); #TODO - delete
return $sQ;
}
....
}
The only changes in comparison to application/contollers/admin/article_list.php are made in method _buildSelectString, the rest of the modul is all copied from there.
Also the other module (oxpr_bonus_list) is build, the changes are just another SQL.
my metadata.php for oxpr_magazine_list:
/**
* Metadata-Version
*/
$sMetadataVersion = '1.1';
/**
* Module information
*/
$aModule = array(
"id" => "oxpr_magazine_list",
"title" => "Printus: Zeitschriften anzeigen",
"thumbnail" => "",
"version" => "0.1",
'description' => array(
'de' => "nur Zeitschriften-Artikel anzeigen",
'en' => "shows only magazine-articles"
),
'templates' => array(
),
'extend' => array(
),
"files" => array(
'oxpr_magazine_list' => 'pr/oxpr_magazine_list/application/controllers/admin/oxpr_magazine_list.php',
),
);
The problem now is.
When clicking on ‘Zeitschriften’ the new oxpr_magazine_list shows up and is working fine. Good.
When clicking on ‘Zugaben’ the same new list (oxpr_magazine_list) shows up.
When clickin on the last menu-point ‘Artikel’ which should show the original article_list - it also shows the filter from oxpr_magazine_list.
My simple question - why?
What is wrong with my code or my thinking?
Thanks for help.