Skip to content
This repository has been archived by the owner on Dec 24, 2020. It is now read-only.

Remove layout when using ajax requests #185

Closed
LarsKlaudius opened this issue Jan 20, 2014 · 15 comments
Closed

Remove layout when using ajax requests #185

LarsKlaudius opened this issue Jan 20, 2014 · 15 comments
Assignees
Labels
Milestone

Comments

@LarsKlaudius
Copy link

Hey,

the different layouts that i create have "Identifier" to. Is there any possibility to render a layout into a layout, like a partial.

$this->layout('name-of-identifier');

do not work.

@PierreRambaud
Copy link
Member

Hi,
Yes that's not the aim of the layout, if you need to include some contents or html you must use view instead of layout. What do you need to do this?

Regards,

@ghost ghost assigned PierreRambaud Jan 20, 2014
@LarsKlaudius
Copy link
Author

Hehe, yeah i thought something like that.
I currently testing a combination of ajax request and some views. My problem is that, if i start a request via ajax of an view, i got it twice.

The reason i think is that i include the partial two times, one in my primary layout which is rendering a hole modal from bootstrap. And the second time into a blank layout that should refreshing the modal-content, if the request was successfully.

@PierreRambaud
Copy link
Member

In your view try this:

$this->viewModel()->getCurrent()->setTerminal(true);

This piece of code logically only render the view.

@LarsKlaudius
Copy link
Author

Hey, i try it out, but did not resolved for 100%. i actually consider about something like $this->viewModel()->setTemplate();

Edit: I edit your message to remove some information about your website, even if it's for test.

@PierreRambaud
Copy link
Member

SetTemplate method only change the template you choose in your document, I think you must terminate the view.

@PierreRambaud
Copy link
Member

You're right, I can't use the setTerminal method in view, I will check it and commit when I have time.

@LarsKlaudius
Copy link
Author

Thank you a lot, let you time with it. I have the feeling that i allready annoying every day with something. X__X

@PierreRambaud
Copy link
Member

Wrong feeling, I'm happy to do that :)

@PierreRambaud
Copy link
Member

Hi again,

I think we can't disable the layout directly in the view :/ I don't find solution, except in adding empty layout like you did.

Regards,

@LarsKlaudius
Copy link
Author

Aaarrrggghhh :(

No problem, i tried out some options too and i agree with you, there is currently no solution. I wanna try out some other ways if i have time, maybe a "Ajax-Module" or something else.

At work they wanna use ajax and i wanna use your CMS, so i need to find something :D
Thanks for your spending time, i will give feedback if i find any solution.

Regards,

@PierreRambaud
Copy link
Member

Otherwise I can add a control in IndexController with a condition that saying "if it's ajax request: setTerminal on ViewModel"?

@LarsKlaudius
Copy link
Author

It is a good idea. It should be the users choice if they wanna terminate the layout for ajax or not, because some ajax request can be made for changing layout options, for example 3 color variations of layout or something else. In my opinion we should add a checkbox or something like that on "Document information" for created documents with some description (Terminate Layout [only needed for ajax] => on/off).

Something like this with a combination of your control and condition idea, that let the cms dynamically, what do you think?

@PierreRambaud
Copy link
Member

Otherwise, I can add a condition in the IndexController (or you can) with if the request is ajax and there's a post or get variable named "terminate layout" exists, execute this code $viewModel->setTerminal(true); ?
With this, no need to specify something in document (where some writers will don't understand what is ajax)

@LarsKlaudius
Copy link
Author

yeah you are right. that's cool.

@LarsKlaudius
Copy link
Author

Works perfect, thank you again for your awesome work.

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

No branches or pull requests

2 participants