我使用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);
我希望能够将文章创建为菜单项,但我甚至不确定从哪里开始。任何帮助表示赞赏。
此致
吉姆
答案 0 :(得分:0)
我认为你使它变得比它需要的复杂一点。事实上它很简单。在管理员面板中,转到您的菜单。
菜单&gt;主菜单(或您想要的菜单)&gt;点击“添加新”&gt;菜单项类型(点击)&gt;点击“文章”展开部分&gt;单篇文章
当你这样做时,你会打开一个选项,在那里你可以选择你想要在该菜单项上的文章。