【发布时间】:2015-04-01 02:46:06
【问题描述】:
我正在尝试在 Concrete5 中为我的客户创建一个自定义仪表板应用程序。我无法在控制器类中获取方法以使页面正常工作。
你可以在这里查看我在混凝土官方论坛上的帖子以获得完全深入的解释:https://www.concrete5.org/community/forums/customizing_c5/call-to-controller-method-throwing-404-page-not-found-error/
这是生成表单的仪表板页面的 view.php 文件
<?php defined('C5_EXECUTE') or die(_("Access Denied."));
$dh = Loader::helper('concrete/dashboard');
$ih = Loader::helper('concrete/interface');
$uNamePosted = "Pants";
$help = 'This add-on works in conjuction with my XML Export add-on ';
$help .= 'this is a new dashboard page which allows you to open these';
$help .= 'XML files, edit and then save them, so that you can then';
$help .= 'import them using Core Commerce Import.';
echo $dh->getDashboardPaneHeaderWrapper(t('XML Viewer'), t($help), 'span8', false);
?>
<div class="ccm-pane-body">
<?php echo $uNamePosted; ?>
<form method="post"
action="<?php echo $this->action('test_form'); ?>">
<input type="text" name="uName" value="" />
<input type="submit" value="Search" />
</form>
</div>
<?php echo $dh->getDashboardPaneFooterWrapper(false); ?>
这是仪表板页面的 controller.php 文件的内容
<?php defined('C5_EXECUTE') or die(_("Access Denied."));
class DashboardCoreCommerceXmlViewerController extends Controller {
public function test_form() {
$uName = $this->post('uName');
$this->set('uNamePosted', $uName);
}
}
预期功能:我在框中输入内容并推送搜索,“pants”的虚拟值更改为我输入的内容
发生了什么:什么都没有,当我点击搜索按钮时,页面重新加载并且没有任何信息被更改。
我正在学习 C5 工作人员的教程:http://andrewembler.com/posts/basic-mvc-in-concrete5/
据我所知,这应该可以工作,但是当我点击搜索时没有任何反应。我已经验证了类中的函数正在被访问,因为 print("sometext");在函数顶部创建以下错误:无法修改标头信息 - 标头已由 public_html 中的(输出开始于 public_html/site/packages/xml_viewer/controllers/dashboard/core_commerce/xml_viewer/controller.php:6)发送/site/concrete/core/libraries/view.php 行 963
这是预期的,因为它在发送标头后打印,但它确实证明了concrete5/.PHP 正在找到该函数,但是该行没有任何反应
$this->set('uNamePosted', $uName);
任何帮助表示赞赏,在此先感谢。甚至他们自己的工作人员的教程也说这应该有效。
【问题讨论】:
-
小说明:我最初遇到了控制器名称的命名空间问题 - 当我点击搜索时出现 404 错误。修复此问题后,我发现该函数在运行时不会执行预期的操作。