我正面臨一個問題。我在Joomla管理員中創建了一篇文章,並且我已經在php文件中創建了一個函數。我必須在那篇文章中調用這個函數。我不知道如何在文章中調用函數。 下面是代碼:Joomla文章裏面的調用函數
class modVodesbalanceHelper {
function deductBalance()
{
$db = JFactory::getDBO();
$result = null;
$user = JFactory::getUser();
if ($user->guest) {
return false;
}
$query = 'SELECT credit' .
' FROM #__vodes_credits' .
' WHERE userid = ' . (int) $user->id
;
$db->setQuery($query);
$result = $db->loadResult();
$result_final=$result-10;
$query = 'update #__vodes_credits SET credit='.$result_final.
' WHERE userid = ' . (int) $user->id
;
//echo $query;
$db->setQuery($query);
$result = $db->loadResult();
}
}
In admin panel, in article i have write this code:
<script>
window.onload=function()
{
var a=confirm("do you want to purchase this credit");
if(a)
{
document.location.href ="index.php?option=com_content&view=featured";
}
else
{
document.location.href="index.php?option=com_content&view=article&id=3";
}
}
</script>
I have to call deductBalance when user click on the "OK" of comfirm box.
Please tell me to sought it .