【问题标题】:Joomla own component settings insert article in popupJoomla 自己的组件设置在弹出窗口中插入文章
【发布时间】:2011-04-21 15:59:36
【问题描述】:

我想设置在后端插入文章 ID。

场景是:用户点击一个按钮,会出现文章列表窗口,然后可以选择文章。文章 ID 将存储在组件配置中。

比我可以在首页填充文章(这部分我知道)

【问题讨论】:

  • 来吧Joomla!是开源的。您所描述的内容是在菜单系统中实现的。您是否查看了该代码并尝试将其移植到您的组件中?

标签: joomla


【解决方案1】:

您需要执行以下操作:

  1. 为 joomla 内容文章元素添加路径
  2. 创建该元素的实例
  3. 显示它

`

<?php
//  I created the element inside of the view, $this is my View. 
//  It can be model/view/controller. Does not matter

//  Include Element
require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_content' . DS . 'elements' . DS . 'article.php';

//  Create Instance
$articleElement = new JElementArticle($this);

//  Output article
echo $articleElement->fetchElement('article', 0, $this, 'myparam');

//  NOTE: name of article_id  element will be myparam[article]
?>

如果你想改变元素的外观,你需要重载/修改元素。这很容易做到,您可以复制site/administrator/components/com_content/elements/article.php,进行更改,您将获得自己的元素版本。不要修改 article.php 组件,你会搞砸 Joomla 的事情,如果你计划在未来更新你的网站......你会在更新后丢失更改。

【讨论】:

  • 它们很简单......但你需要知道一些事情。了解框架非常重要,如果您想更深入地了解框架,请收藏此页面docs.joomla.org/Framework。知识就是力量!
猜你喜欢
  • 1970-01-01
  • 2011-04-20
  • 2015-03-27
  • 1970-01-01
  • 2014-11-03
  • 2015-06-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多