2013-07-21 27 views

回答

12

從這裏回憶,請忍受一些不準確,但它應該足以讓你走。

$input = JFactory::getApplication()->input; 

// should be article, categories, featured, blog... 
$view = $input->get('view'); 

// if it's a category view, this will be the category id, else the article id 
$id = $input->getInt('id'); 

// in an article view, this will be the cat id. 
$catid = $input->getInt('catid'); 

// this is the menu item id i.e. what you call page id I guess. 
$Itemid = $input->getInt('Itemid'); 
+0

這是工作感謝..順便說一下..我怎麼知道什麼時候可以在$ input變量上使用「input」語句,或者使用其他語句,比如你已經做了什麼。謝謝 –

+0

通常你可以使用$ input變量,如果你像我在代碼的第1行那樣定義它的話。否則它將被取消分配。我建議你閱讀更多的變量範圍:http://php.net/manual/en/language.variables.scope.php –

+0

謝謝兄弟!非常有幫助 – Brent

相關問題