Joomla 3.x.x Shortcode插件和模块出错

时间:2017-08-20 12:19:05

标签: plugins joomla joomla3.0 joomla-extensions joomla-module

我想为可以添加倒数计时器的文章编写一个Joomla加载项。我希望能够使用例如短代码public void preWorks() { asyncTask = new AsyncTask<Void, Void, Void>() { @Override protected Void doInBackground(Void... Params) { int count = 0; String[] txt_files = {"/l12.txt", "/l13.txt"}; for (String fileName : txt_files) { File file = new File(Environment.getExternalStorageDirectory() .getAbsolutePath() + "/do" + fileName); String response = ""; if (!(file.exists())) { //file doesn't exist!! AndroidAuthSession session = null; try { session = buildSession(); } catch (DropboxException e) { e.printStackTrace(); } dropboxAPI = new DropboxAPI<>(session); Dir.mkdirs(); File fileDB = new File(file + fileName .substring(fileName.lastIndexOf('.'))); try { FileOutputStream outputStream = new FileOutputStream(fileDB); TextDownloader.dropboxAPI.getFile(fileName, null, outputStream, null); return null; } catch (FileNotFoundException e) { e.printStackTrace(); } catch (DropboxException e) { e.printStackTrace(); } } BufferedReader br; try { br = new BufferedReader(new InputStreamReader(new FileInputStream (file), "cp1252")); for (String line; (line = br.readLine()) != null; response += line + '\n'); count = response.length() - response.replace(";", "").length(); } catch (FileNotFoundException e) { } catch (IOException e) { } String preFileName = fileName.substring(0, fileName.length() - 4); PreferenceManager.getDefaultSharedPreferences(TextDownloader.this) .edit() .putString(preFileName, response).apply(); } return null; } @Override protected void onPostExecute(Void param) { Toast.makeText(TextDownloader.this, "your file has been downloaded", Toast .LENGTH_SHORT) .show(); Intent intent = new Intent(TextDownloader.this, MainActivity.class); TextDownloader.this.startActivity(intent); } @Override protected void onPreExecute() { super.onPreExecute(); //tv1.setText("your file is getting downloaded"); Toast.makeText(TextDownloader.this, "your file is getting downloaded", Toast.LENGTH_SHORT) .show(); } }; asyncTask.execute(); } 来运行它。我不知道如何在短代码中添加参数并将它们移动到我的模块中。在我的柜台上替换[countdowntimer date = "23-9-2017" time = "13:42"]我已经完成了。

[countdowntimer]

1 个答案:

答案 0 :(得分:1)

在标题中你提到你有一个&#34;错误&#34;。但是你不能说出你的代码究竟是什么问题(除此之外它没有用)。 您可以使用现有的扩展程序代替对自己的插件进行编码:https://extensions.joomla.org/extension/modules-anywhere/。此扩展程序可以完全按照您的意愿执行。

但是如果您想创建自己的插件,请查看JModuleHelper类以使用参数加载模块(请参阅:https://api.joomla.org/cms-3/classes/JModuleHelper.html)。 JModuleHelper::renderModule的结果是一个可附加到$article->text

的字符串