User tests: Successful: Unsuccessful:
Pull Request for Issue #11202 .
Create a template file to get only the componet's output.
Add ?tmpl=ajax
at the end of the URL i.e. www.site.any/alias-example?tmpl=ajax
The component's HTML should be available with no html, head, body tags.
Status | New | ⇒ | Pending |
Labels |
Added:
?
|
@brianteeman for example: when using ajax to get an article or other component's output.
And how is this different to the existing solution tmpl=component
@brianteeman with component we can get the component output in addition to the JS, CSS files and the html, head, body tags:
www.site.any/alias-example?tmpl=component
<html>
<head>
// JS and CSS files loads here
</head>
<body>
<div id="mycomponent">
// component's code loads here
</div>
</body>
</html>
If we want to load just the component while using ajax, this approach is much better:
www.site.any/alias-example?tmpl=ajax
<div id="mycomponent">
// component's code loads here
</div>
IMO it's a specialized case that doesn't belong in core (see the referenced issue). And it also seems like a bad idea to support a manner in core which makes a request for a HTML document that does not serve a proper HTML response. This IMO is exactly what the other request formats are designed for and I disagree with adding what is essentially a hack to make a full HTML request "compatible" with AJAX which is better served receiving JSON response bodies.
And for reference yes you can render a component's layout from a controller that's been requested in a non-HTML format. Your $controller->getView()
call would need to specify the HTML formatted view to get it to load that one specifically versus using the format
parameter from the request.
Status | Pending | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2016-07-19 18:37:28 |
Closed_By | ⇒ | htmgarcia |
What is the use case for this?