繁体   English   中英

创建文章作为菜单项

[英]Create article as menu item

我对使用Joomla(3.3)相当陌生,我按照此处发布的说明使用此代码以编程方式创建文章:

<?php
define('_JEXEC', 1);
define('DS', DIRECTORY_SEPARATOR);

if (file_exists(dirname(__FILE__) . '/defines.php')) {
   include_once dirname(__FILE__) . '/defines.php';
}
if (!defined('_JDEFINES')) {
   define('JPATH_BASE', dirname(__FILE__));
   require_once JPATH_BASE.'/includes/defines.php';
}

define('JPATH_COMPONENT_ADMINISTRATOR', JPATH_BASE . DS . 'administrator' . DS . 'components' . DS . 'com_content');
require_once JPATH_BASE.'/includes/framework.php';


require_once JPATH_BASE. "/administrator/components/com_content/models/article.php";


$app = JFactory::getApplication('site', array('session' => false));

$new_article = new ContentModelArticle();

$data = array(
    'catid' => '17',
    'title' => 'Title',
    'introtext' => '<h4><strong>Intro Text Here</strong></h4>',
    'fulltext' => '<p>This is the full text paragraph </p>'
    'state' => 1,
);
$new_article->save($data);

我希望能够将文章创建为菜单项,但我什至不知道从哪里开始。 任何帮助表示赞赏。

问候

吉姆

我认为您正在使它变得比所需的更为复杂。 实际上,这很简单。 在管理员面板中,转到菜单。

菜单>主菜单(或所需菜单)>单击“添加新”>菜单项类型(单击)>单击“文章”以展开该部分>“单个文章”

当您执行此操作时,将打开一个选项,您可以在其中选择要显示在该菜单项上的文章。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM