doulin1867 2015-03-30 22:49
浏览 33
已采纳

Concrete5 - 类方法不起作用

I am trying to create a custom dashboard application in Concrete5 for a client of mine. I am having trouble getting methods inside the controller class for the page to work.

You can view my post on the official concrete5 forums for a completely in-depth explanation here: https://www.concrete5.org/community/forums/customizing_c5/call-to-controller-method-throwing-404-page-not-found-error/

This is my view.php file for the dashboard page which generates the form

<?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); ?>

This is the contents of my controller.php file for the dashboard page

<?php  defined('C5_EXECUTE') or die(_("Access Denied."));



    class DashboardCoreCommerceXmlViewerController extends Controller {
      public function test_form() {
        $uName = $this->post('uName');
        $this->set('uNamePosted', $uName);
        }
    }

Expected functionality: I type something in the box and push search, the dummy value of 'pants' is changed to what I typed

What is happening: Nothing, when I hit the search button the page reloads and no information is changed.

I am following a tutorial by a C5 staff member located here: http://andrewembler.com/posts/basic-mvc-in-concrete5/

As far as I can tell this should work but nothing happens when I hit search. I have verified that the function inside the class is being accessed because a print("sometext"); at the top of function creates the following error: Cannot modify header information - headers already sent by (output started at public_html/site/packages/xml_viewer/controllers/dashboard/core_commerce/xml_viewer/controller.php:6) in public_html/site/concrete/core/libraries/view.php on line 963

Which is expected because its printing after headers have been sent, but it does prove that concrete5/.PHP is finding the function however nothing happens with the line

$this->set('uNamePosted', $uName);

Any help is appreciated, thanks in advance. Even the tutorial from their own staff member says this should be working.

  • 写回答

1条回答 默认 最新

  • dqlxtv1452 2015-03-31 18:46
    关注

    Answered on Conrete5 forums.

    I had a brain fart and was setting the variable to 'pants' inside view.php not inside controller.php

    Doh!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler