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

Not using the subdirectory for view file #3

Closed
gauravmak opened this issue Apr 15, 2015 · 12 comments
Closed

Not using the subdirectory for view file #3

gauravmak opened this issue Apr 15, 2015 · 12 comments

Comments

@gauravmak
Copy link

Mark,

I am using this plugin in my app and I needed to skip the subdirectory for view file like this src\Template\ajax\ACTION_NAME.ctp as I am using a new controller for ajax requests.

So, I changed the code here https://github.com/dereuromark/cakephp-ajax/blob/master/src/View/AjaxView.php#L68-L70 and set it to -
$this->subDir = null;

Now, I am not sure if this make a good feature and if yes, how to make this option configurable so that it can be put in the repository. What are you comments on it?

@dereuromark
Copy link
Owner

As the code shows that would not work. You would need to set it to empty string '' or false in your controller.

@dereuromark
Copy link
Owner

@gauravmak
Copy link
Author

Thank you for the update.

Sorry,if I misunderstand anything but setting it to '' or false did not work for me initially. and after checking the test, I came to know setting it to false might work.
As per this - https://github.com/dereuromark/cakephp-ajax/blob/master/tests/TestCase/View/AjaxViewTest.php#L123

So, finally making the change as I specified above did work for me :
I commented these 3 lines - https://github.com/dereuromark/cakephp-ajax/blob/master/src/View/AjaxView.php#L68-L70 and added -
$this->subDir = null;

Please correct me if I am wrong anywhere. I accept my knowledge with this is very limited and I am not aware about all the related parts of the framework.

@dereuromark
Copy link
Owner

So in your case you still have the problem?
What is your controller code?

@dereuromark dereuromark reopened this Apr 15, 2015
@gauravmak
Copy link
Author

No, my problem is solved after the above change. My view is in _src\Template\CONTROLLER_NAME_ directory. and working. There is not much code yet. I am yet to put everything as per my requirement.

<?php
namespace App\Controller;

use App\Controller\AppController;

/**
 * Ajax Controller
 */
class AjaxController extends AppController
{
    public function initialize()
    {
        $this->loadComponent('Ajax.Ajax');
        $this->request->allowMethod('ajax');
    }

    public function favorites() {
        // all code here
    }
}

@dereuromark
Copy link
Owner

The idea is that you have not to change the source code here.
So instead, you should be using

$this->subDir = false;

in your controller action, which you do not do yet it seems.

@gauravmak
Copy link
Author

I had tried that before making change in source code but it didn't work.

@dereuromark
Copy link
Owner

Can you try to make it work without changing the source code? if nothing works, then we have to find a solution.

@gauravmak
Copy link
Author

I did try a couple of things but failed. I am a novice with this so.
But, not to worry, I will try more. Thank you for the challenge.
I will update after trying my best.

@gauravmak
Copy link
Author

No luck :( no options.
I think source code needs to be changed.

@dereuromark
Copy link
Owner

Please check if 3.1 (and the current head of this plugin) fixes the issue.

With

 $this->subDir = false;

@dereuromark
Copy link
Owner

Should be good now.

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

No branches or pull requests

2 participants