Code Monkey home page Code Monkey logo

Comments (6)

mozillamonks avatar mozillamonks commented on July 30, 2024 1

So, I think I found what I was doing wrong but I'm not sure this is correct still.

I have set up the parseExtensions version (which, sound be Router::extensions I realized after trial and error) from the README. My controller has:

    public $components = [
        'RequestHandler' => [
            'viewClassMap' => ['csv' => 'CsvView.Csv']
        ]
    ];

and my function is:

    public function staff()
    {
        $this->paginate = [
            'contain' => ['Users', 'Conventions']
        ];

        $query = $this->People->find();
        $query->where(['role !=' => 6]);

        $this->set('people', $this->paginate($query));
        $this->set('_serialize', ['people']);
        $this->set('_extract', ['id', 'name', 'convention.name']);
    }

This works! It feels like _extract should be ['Person.id', 'Person.name', 'Convention.name'], which is what the readme shows and what had messed me up before.

from cakephp-csvview.

josegonzalez avatar josegonzalez commented on July 30, 2024

When you use models with relations, you're expected to use the _serialize option to pull out the data you want.

I didn't want to "automatically" pull out the data, since it gets pretty weird when you start getting into multiple levels of relationships, and probably best handled by the user with the aforementioned option.

Does that explanation help?

from cakephp-csvview.

mozillamonks avatar mozillamonks commented on July 30, 2024

Somewhat, although I don't see how to pull out data with _serialize, I'd played a bit with _extract but didn't seem to get the correct result either. Would you be kind enough as to provide an example?

from cakephp-csvview.

josegonzalez avatar josegonzalez commented on July 30, 2024

oh sorry yeah, _extract. Basically It's the same syntax as Hash::get(), so anything that works there works here.

Do you have an example entity/relation set that you can provide and the _extract code you used? We can help set you straight if we know what you're dealing with.

from cakephp-csvview.

josegonzalez avatar josegonzalez commented on July 30, 2024

Ah! Okay, the readme is definitely a bit wrong, and is using the array conventions from 2.x instead of the toArray output in 3.x. Can you file a PR against the readme, updating it to remove the extra table prefix, and normalizing the capitalization?

from cakephp-csvview.

mozillamonks avatar mozillamonks commented on July 30, 2024

Sure!

from cakephp-csvview.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.