Joomla自己的组件设置在弹出窗口中插入文章

时间:2010-10-06 06:40:54

标签: joomla

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

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

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

1 个答案:

答案 0 :(得分:1)

您需要执行以下操作:

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

    <?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的事情,如果你计划将来更新你的网站......你会在更新后松动更改。

相关问题