如果有任何更新可用,Joomla會在登錄後臺後進行檢查。如果是,您可以點擊「查看更新」查看概覽。但是我想顯示一個類似的消息,關於由我開發的擴展的更新('有更新可用')。我嘗試了一些東西,但到目前爲止我沒有管理。有什麼建議麼?如何爲Joomla擴展程序創建消息「更新可用」?
回答
這是我爲我的組件遵循的代碼。您可以使用相同的,則須─> tmpl->如default.php文件
<?php $user = JFactory::getUser(); ?>
<div class="UpdatesPage" style="margin-top: 8px">
<?php
$xml = JFactory::getXML(JPATH_ADMINISTRATOR .'/components/com_mycomponent/manifest.xml');//Path to your existing manifest file.
$existingversion = (string)$xml->version;
$url = 'http://example.com/downloads/mycomponent.xml';
//$url is path to your xml file which stores the latest version.
$ch = curl_init($url);//Execute curl and get the xml data available in my server
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_exec($ch);
$retcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
// 400 means not found, 200 means found.
curl_close($ch);
if($retcode == 200){
$xml2 = JFactory::getXML($url,true);
$latestversion = $xml2->update->version;
} else {
$latestversion = "";
}
?>
<h2>Version Update</h2>
<?php
if (version_compare($latestversion, $existingversion) > 0) {
echo "<span style='color:#AFA;text-align:center;'>The version installed is ".$existingversion."</span><br />";
echo "<span style='color:red;text-align:center;'>The latest version is ".$latestversion."</span><br />";
} else {
echo "<span style='color:green;text-align:center;'>You have the Latest version</span>";
}
?>
</div>
這是我的服務器的XML文件,其中更新它使我的組件用戶可以看到,當他們訪問我的組件更新頁面
<?xml version="1.0" encoding="utf-8"?>
<updates>
<update>
<name><![CDATA[My Component]]></name>
<description><![CDATA[Download Component]]></description>
<element>pkg_mycomponent</element>
<type>package</type>
<client>0</client>
<version>1.1.1</version>
<infourl title="example.com">http://www.example.com</infourl>
<downloads>
<downloadurl type="full" format="zip">https://example.com/index.php?option=com_mycomponent</downloadurl>
</downloads>
<tags>
<tag>stable</tag>
</tags>
<maintainer><![CDATA[Amit Ray]]></maintainer>
<maintainerurl>http://www.example.com</maintainerurl>
<section>Testing</section>
<targetplatform name="joomla" version="3"/>
</update>
</updates>
謝謝,這工作正常 – Franky
仍然是一個問題:我的更新xml和更新文件是在一個網站與https,這似乎沒有問題,當我在當地工作。然後腳本工作正常。當我使用https在實際站點上嘗試腳本時,出現無法讀取來自我的updatesite的XML文件的錯誤。另一方面,Joomla確實在更新列表中顯示更新正確。腳本中可以解決這個問題嗎? – Franky
@Franky在'$ url ='http://example.com/downloads/mycomponent.xml';'你使用的是http還是https?正如你所說這是https,所以你需要改變這個變量爲https。所以你的網址應該是'url ='https://example.com/downloads/mycomponent.xml';' –
- 1. Joomla擴展更新通知
- 2. 如何構建Joomla擴展?
- 3. 爲Magento中的擴展創建更新
- 4. 如何爲瀏覽器擴展/插件創建自動更新程序?
- 5. 如何爲.JAR擴展名的手機創建應用程序?
- 6. 如何爲vb.net應用程序創建Adobe AIR擴展?
- 7. 如何使用CMake在Xcode中爲應用程序擴展創建新目標?
- 8. 如何在CAPL中創建擴展消息ID?
- 9. NPM是如何爲其更新消息創建邊界的?
- 10. iOS消息擴展程序如何直接切換主機應用程序
- 11. 如何從Chrome擴展程序接收本地消息至Mac應用程序?
- 12. 如何創建可擴展xml
- 13. Safari擴展 - 消息
- 14. 如何使用PHP爲可擴展樹創建3,4級陣列?
- 15. 無法爲通用Windows應用程序創建vsix擴展
- 16. 創建可擴展枚舉用於可擴展接口
- 17. 如何創建Dreamweaver擴展?
- 18. 如何創建擴展MKMapView
- 19. 如何創建jinja2擴展?
- 20. 如何創建Devise擴展?
- 21. 如何更新擴展Microsoft.Web.Mvc.DataAnnotations.DataAnnotationsModelBinder的舊MVC應用程序?
- 22. Chrome擴展程序動態創建HTML
- 23. 我應該如何創建可更新的應用程序?
- 24. (消息傳遞)隊列如何擴展?
- 25. 窄帶可擴展消息格式
- 26. Chrome擴展程序自動更新
- 27. 其他Chrome擴展程序可以讀取我的擴展程序寫入的日誌消息嗎?
- 28. iOS 10消息擴展應用程序:如何獲取由此功能創建的MSSticker?
- 29. 如何使用C#應用程序將消息發送到Firefox擴展?
- 30. iOS共享擴展應用程序圖標未更改爲新
也許檢查Akeeba備份代碼,它具有您描述的功能。 –