? Success

User tests: Successful: Unsuccessful:

avatar htmgarcia
htmgarcia
19 Jul 2016

Pull Request for Issue #11202 .

Summary of Changes

Create a template file to get only the componet's output.

Testing Instructions

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.

avatar htmgarcia htmgarcia - open - 19 Jul 2016
avatar htmgarcia htmgarcia - change - 19 Jul 2016
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 19 Jul 2016
Labels Added: ?
avatar brianteeman
brianteeman - comment - 19 Jul 2016

What is the use case for this?

avatar htmgarcia
htmgarcia - comment - 19 Jul 2016

@brianteeman for example: when using ajax to get an article or other component's output.

avatar brianteeman
brianteeman - comment - 19 Jul 2016

And how is this different to the existing solution tmpl=component

avatar htmgarcia
htmgarcia - comment - 19 Jul 2016

@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>
avatar mbabker
mbabker - comment - 19 Jul 2016

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.

avatar brianteeman
brianteeman - comment - 19 Jul 2016

I agree with @mbabker

avatar htmgarcia htmgarcia - change - 19 Jul 2016
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2016-07-19 18:37:28
Closed_By htmgarcia
avatar htmgarcia htmgarcia - close - 19 Jul 2016

Add a Comment

Login with GitHub to post a comment