Oleh: addthe | Agustus 7, 2007

Submit News Joomla Tidak Keluar Category

Ini Yang Keren Cuman Judulnya Saja

Beberapa saat yang lalu ada yang ngomong sama saya kalau dia tidak bisa melakukan submit news pada situs joomla kami. Setelah saya check pada user manager nya joomla, semuanya kelihatan beres dan diapun sudah berada pada posisi seharusnya yakni menjadi seorang author. Kelihatannya ada yang salah pada script front endnya joomla kalau gak salah pada com_content nya, akhirnya google pun kuminta dengan sangat untuk bisa memberikan solusi atas kekhawatiran yang selama ini aku rasakan. Dan alhamdulillah ketemu juga pada sebuah titik terang tentang semuanya.

Buka file content.php yang berada di dalamnya com_content kemudian cari fungsi yang dianugerahi nama

function editItem

Silahkan anda cari terlebih dahulu, jika sudah maka lakukan perubahan pada scriptnya menjadi seperti ini

function editItem( $uid, $gid, &$access, $sectionid=0, $task, $Itemid ){
global $database, $mainframe, $my;
global $mosConfig_absolute_path, $mosConfig_live_site;

$row = new mosContent( $database );
// load the row from the db table
$row->load( $uid );

if ( $uid ) {
// existing record
if ( !( $access->canEdit || ( $access->canEditOwn && $row->created_by == $my->id ) ) ) {
mosNotAuth();
return;
}
} else {
// new record
if (!($access->canEdit || $access->canEditOwn)) {
mosNotAuth();
return;
}
}

if ( $uid ) {
$sectionid = $row->sectionid;
}

if ( $sectionid == 0 ) {
$where = “\n WHERE section NOT LIKE ‘%com_%’”;
} else {
$where = “\n WHERE section=’$sectionid’”;
}
$lists = array();

/*************** BEGIN MODIFY ********************/
// get the type name – which is a special category
//$database->setQuery( “SELECT name FROM #__sections WHERE id=$sectionid” );
//$section = $database->loadResult();
// get the type name – which is a special category
if ($row->sectionid){
$query = “SELECT name FROM #__sections WHERE id=$row->sectionid”;
$database->setQuery( $query );
$section = $database->loadResult();
$contentSection = $section;
} else {
$query = “SELECT name FROM #__sections WHERE id=$sectionid”;
$database->setQuery( $query );
$section = $database->loadResult();
$contentSection = $section;
}
/*************** END MODIFY ********************/
// fail if checked out not by ‘me’
if ($row->checked_out && $row->checked_out <> $my->id) {
echo”alert(‘The module “.$row->title.” is currently being edited by another person.’)”;
mosRedirect( ‘index.php?option=com_content&task=view&id=’. $row->id );
}

if ( $uid == 0 ) {
$row->catid = 0;
}

if ( $uid ) {
$row->checkout( $my->id );
if (trim( $row->publish_down ) == “0000-00-00 00:00:00″) {
$row->publish_down = “Never”;
}
if (trim( $row->images )) {
$row->images = explode( “\n”, $row->images );
} else {
$row->images = array();
}
$database->setQuery( “SELECT name from #__users”
. “\n WHERE id = “. $row->created_by
);
$row->creator = $database->loadResult();

$database->setQuery( “SELECT name from #__users”
. “\n WHERE id = “. $row->modified_by
);
$row->modifier = $database->loadResult();

$database->setQuery( “SELECT content_id from #__content_frontpage”
. “\n WHERE content_id = “. $row->id
);
$row->frontpage = $database->loadResult();
} else {
$row->sectionid = $sectionid;
$row->version = 0;
$row->state = 0;
$row->ordering = 0;
$row->images = array();
$row->publish_up = date( ‘Y-m-d’, time() );
$row->publish_down = ‘Never’;
$row->creator = 0;
$row->modifier = 0;
$row->frontpage = 0;
$row->catid = NULL;
}
/*************** BEGIN MODIFY ********************/
$javascript = “onchange=\”changeDynaList( ‘catid’, sectioncategories, document.adminForm.sectionid.options[document.adminForm.sectionid.selectedIndex].value, 0, 0);\”";

$query = “SELECT s.id AS value, s.title AS text”
. “\n FROM #__sections AS s”
. “\n ORDER BY s.ordering”;
$database->setQuery( $query );
if ( $sectionid == 0 ) {
$sections[] = mosHTML::makeOption( ‘-1′, ‘Select Section’ );
$sections = array_merge( $sections, $database->loadObjectList() );
$lists['sectionid'] = mosHTML::selectList( $sections, ’sectionid’, ‘class=”inputbox” size=”1″ ‘. $javascript, ‘value’, ‘text’ );
} else {
$intval = intval( $row->sectionid);
$dbLoadObjectList = $database->loadObjectList();
$lists['sectionid'] = mosHTML::selectList( $dbLoadObjectList, ’sectionid’, ‘class=”inputbox” size=”1″ ‘. $javascript, ‘value’, ‘text’, $intval );
}

$sections = $database->loadObjectList();

$sectioncategories = array();
$sectioncategories[-1] = array();
$sectioncategories[-1][] = mosHTML::makeOption( ‘-1′, ‘Select Category’ );
foreach($sections as $section) {
$sectioncategories[$section->value] = array();
$query = “SELECT id AS value, name AS text”
. “\n FROM #__categories”
. “\n WHERE section=’$section->value’”
. “\n ORDER BY ordering”;
$database->setQuery( $query );
$rows2 = $database->loadObjectList();
foreach($rows2 as $row2) {
$sectioncategories[$section->value][] = mosHTML::makeOption( $row2->value, $row2->text );
}
}

// get list of categories
if ( !$row->catid && !$row->sectionid ) {
$categories[] = mosHTML::makeOption( ‘-1′, ‘Select Category’ );
$lists['catid'] = mosHTML::selectList( $categories, ‘catid’, ‘class=”inputbox” size=”1″‘, ‘value’, ‘text’ );

} else {
$query = “SELECT id AS value, name AS text”
. “\n FROM #__categories”
. $where
. “\n ORDER BY ordering”;
$database->setQuery( $query );
$categories = $database->loadObjectList();
$lists['catid'] = mosHTML::selectList( $categories, ‘catid’, ‘class=”inputbox” size=”1″‘, ‘value’, ‘text’, intval( $row->catid ) );

}

/*************** END MODIFY ********************/
// calls function to read image from directory
$pathA = $mosConfig_absolute_path .’/images/stories’;
$pathL = $mosConfig_live_site .’/images/stories’;
$images = array();
$folders = array();
$folders[] = mosHTML::makeOption( ‘/’ );
mosAdminMenus::ReadImages( $pathA, ‘/’, $folders, $images );
// list of folders in images/stories/
$lists['folders'] = mosAdminMenus::GetImageFolders( $folders, $pathL );
// list of images in specfic folder in images/stories/
$lists['imagefiles'] = mosAdminMenus::GetImages( $images, $pathL );
// list of saved images
$lists['imagelist'] = mosAdminMenus::GetSavedImages( $row, $pathL );

// make the select list for the states
$states[] = mosHTML::makeOption( 0, _CMN_UNPUBLISHED );
$states[] = mosHTML::makeOption( 1, _CMN_PUBLISHED );
$lists['state'] = mosHTML::selectList( $states, ’state’, ‘class=”inputbox” size=”1″‘, ‘value’, ‘text’, intval( $row->state ) );

// build the html select list for ordering
$query = “SELECT ordering AS value, title AS text”
. “\n FROM #__content”
. “\n WHERE catid = ‘$row->catid’”
. “\n ORDER BY ordering”
;
$lists['ordering'] = mosAdminMenus::SpecificOrdering( $row, $uid, $query, 1 );

/*************** BEGIN MODIFY ********************/
// build list of categories
//$lists['catid'] = mosAdminMenus::ComponentCategory( ‘catid’, $sectionid, intval( $row->catid ) );
/*************** END MODIFY ********************/

// build the select list for the image positions
$lists['_align'] = mosAdminMenus::Positions( ‘_align’ );
// build the html select list for the group access
$lists['access'] = mosAdminMenus::Access( $row );

/*************** BEGIN MODIFY ********************/
//HTML_content::editContent( $row, $contentSection, $lists, $images, $access, $my->id, $sectionid, $task, $Itemid );
HTML_content::editContent( $row, $contentSection, $lists, $images, $access, $my->id, $sectionid, $task, $Itemid, $sectioncategories );
/*************** END MODIFY ********************/
}

maka insya Allah dengan berbekal doa dan juga kemauan maka submit news pada front end untuk author sudah bisa digunakan.

Berdasarkan pengalamanku file itu saja yang diganti sudah cukup untuk membuat semuanya kembali berjalan, paling tidak sampai saat tulisan ini dikeluarkan.

referensi: forum mamboserver


Tanggapan

  1. C1rXpL hi! hice site!


Beri tanggapan

Your response:

Kategori