Joomla 3.x 前台 Content Category List 啟用發佈選項
Joomla 3 內建前台沒有像後台列表頁一樣有發佈按鈕可以快速切換,可以使用以下方法在前台列表頁啟用發佈按鈕喔!
打開你的前台列表頁,將發佈按鈕的 HTML 貼在你要的表格上
1 2 3 4 5 6 7 8 9 10
| <?php $menu = JFactory::getApplication()->getMenu(); $active = $menu->getActive(); $itemId = $active->id; $juri = JURI::getInstance(); $returnURL = base64_encode($juri->toString()); ?> <a class="btn btn-micro active hasTooltip" href="index.php?option=com_content&task=article.state&a_id=<?php echo $article->id; ?>&return=<?php echo $returnURL; ?>&Itemid=<?php echo $itemId; ?>" title=" " data-original-title=""> <i class="<?php echo $article->state ? 'icon-publish' : 'icon-unpublish' ; ?>" style="<?php echo $article->state ? 'color:#51a351' : 'color:#bd362f' ;?>"></i> </a>
|
打開 components/com_content/controllers/article.php 加入以下程式:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| public function state() { if (!JFactory::getUser()->authorise('core.edit','com_content')) { return JError::raiseError(500,'你無權使用。'); } $aid = JRequest::getInt('a_id'); $returnURL = JRequest::getString('return'); $model = $this->getModel(); $table = $model->getTable(); $table->load($aid);
$table->state = ($table->state == 0) ? 1 : 0; $table->save(array());
$this->setRedirect(base64_decode($returnURL)); }
|
醬就完成啦~~!!