Single-page editing interface in the Dashboard

Permalink
Hi all

I'd like to create a single-page editing interface in the Dashboard for a new set of functionality I'll be developing for a client soon. I've had a look at Andrew's example FAQ howto, but it's a bit more complicated than what I'm looking for.. basically what I want to do is to be able to create pages using a particular pagetype along with some custom attributes and some content for the main areas. I don't think this'll be too hard, but I can't get my head round the example FAQ's code.

Has anyone done anything like this before? Would you be willing to share your experience/tips?

Cheers!

melat0nin
 
RadiantWeb replied on at Permalink Best Answer Reply
RadiantWeb
the FAQ example is as easy as you can get in this regard. It follows nearly exactly what you want to do...plus or minus. you can't get any closer than that.

OOP and MVC is the correct way of doing things. But "I don't think it's that hard" is a relative statement, and I would prepare to pay $$$ for programmers of a caliber that can nicely work their way around and create apps.

C
ScottC replied on at Permalink Reply
ScottC
I marked Chad's reply as best answer.

I totally agree, simplefaq is probably the easiest and best coded example you are going to find.

I just learned a few things checking out how they did the error stuff.

This is something that is really nice to learn as a developer. A LOT of companies want this sort of functionality, some are willing to pay for it, most aren't and just go ahead and build the pages manually leveraging underutilized employees i guess?!
melat0nin replied on at Permalink Reply
melat0nin
I think you guys are right... I guess I just need to be a bit more patient in getting to grips with c5's underbelly :)
melat0nin replied on at Permalink Reply
melat0nin
Right well I'm diving in (always the best way!) and trying to use Andrew's how-to to create a basic interface.

I'm trying to create a page programatically from my new single page in the Dashboard, but I keep getting errors.

Here's my controller.php:

<?php 
defined('C5_EXECUTE') or die(_("Access Denied.")); 
class DashboardJobsController extends Controller {
   public $helpers = array('html','form');
   public function on_start() {
      Loader::model('page_list');
      $this->error = Loader::helper('validation/error');
   }
   public function view() {
      /*$this->setupForm();
      if ($this->isPost()) {
         $parent = Page::getByID($this->post('cParentID'));
            $ct = CollectionType::getByID($this->post('ctID'));            
            $data = array('cName' => $this->post('pageTitle'));
            $p = $parent->add($ct, $data);


...you can see it's a simplified version of Andrew's. I want to start with the basics then build up slowly as I can get things to work.

Here's my view.php:

<?php
      $task = 'add';
   ?>
<form method="post" action="<?php echo $this->action($task)?>" id="jobs-form">
   <strong><?php echo $form->label('pageTitle', t('Page Title'))?></strong>
   <div><?php echo $form->text('pageTitle', $pageTitle, array('style' => 'width: 730px'))?></div>
<?php /*   <br/>
   <strong><?php echo $form->label('faqDescription', t('Brief Answer'))?></strong>
   <div><?php echo $form->textarea('faqDescription', $faqDescription, array('style' => 'width: 730px; height: 100px'))?></div>
   <br/>         
   <strong><?php echo $form->label('cParentID', t('Section'))?></strong>
   <?php  if (count($sections) == 0) { ?>
      <div><?php echo t('No sections defined. Please create a page with the attribute "faq_entry" set to true.')?></div>
   <?php  } else { ?>
      <div><?php echo $form->select('cParentID', $sections, $cParentID)?></div>


The error I'm getting is:

Call to a member function getPackageID() on a non-object


The problem (I think) is with these lines in controller.php:

$parent = Page::getByID($this->post('cParentID'));
            $ct = CollectionType::getByID($this->post('ctID'));


But i can't see where I'm going wrong, when compared with Andrew's code.

I'm a total newb at c5 development so please bear with me. Any help would be much appreciated - I'm beginning to see the power of c5 unfold before me!