Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need extra line of code in one of the examples #25

Closed
paulmorriss opened this issue Mar 7, 2014 · 5 comments · Fixed by #26
Closed

Need extra line of code in one of the examples #25

paulmorriss opened this issue Mar 7, 2014 · 5 comments · Fixed by #26

Comments

@paulmorriss
Copy link

I'm using Cake PHP 2.4.5. When I used the code as you have in the snippet above the line

// Access /posts/export.csv to get the data as csv

I found that I also needed the line

$this->viewClass = 'CsvView.Csv';

otherwise I got the error

View file "\app\View\csv\export.ctp" is missing.

@josegonzalez
Copy link
Member

Can you paste the whole snippet? I dont know which one you are referring to.

@paulmorriss
Copy link
Author

// In your routes.php file:
Router::parseExtensions('csv');

// In your controller:
public $components = array(
    'RequestHandler' => array(
        'viewClassMap' => array('csv' => 'CsvView.Csv)
    )
);

public function export() {
    $posts = $this->Post->find('all');
    $_serialize = 'posts';
    $_header = array('Post ID', 'Title', 'Created');
    $_extract = array('Post.id', 'Post.title', 'Post.created');

    $this->set(compact('posts', '_serialize', '_header', '_extract'));
}

@josegonzalez
Copy link
Member

We just updated the docks so it would work properly. The docs you just
pasted are now correct. Previously they were omitting the viewClassMap.

On Fri, Mar 7, 2014 at 1:40 PM, Paul Morriss notifications@github.comwrote:

// In your routes.php file:Router::parseExtensions('csv');
// In your controller:public $components = array(
'RequestHandler' => array(
'viewClassMap' => array('csv' => 'CsvView.Csv) ));
public function export() { $posts = $this->Post->find('all'); $_serialize = 'posts'; $_header = array('Post ID', 'Title', 'Created'); $_extract = array('Post.id', 'Post.title', 'Post.created');
$this->set(compact('posts', '_serialize', '_header', '_extract'));}

Reply to this email directly or view it on GitHubhttps://github.com//issues/25#issuecomment-37053871
.

@paulmorriss
Copy link
Author

Thanks for sorting that out. However there's a missing close quote after CsvView.Csv.

@dereuromark
Copy link
Member

Fixed with #27

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants