User tests: Successful: Unsuccessful:
See this discussion for why template support is needed in com_ajax
.
I have basically copied the module logic which requires a helper file in the root of the extension with specific class & method names.
See the below code to quickly test support for this from the front end & the back end.
class tplProtostarHelper
{
public static function getAjax()
{
return __METHOD__ . "\n\n" . JText::_( 'TPL_PROTOSTAR_XML_DESCRIPTION' );
}
public static function mySuperAwesomeMethodToTriggerAjax()
{
return __METHOD__ . "\n\n" . JText::_( 'TPL_PROTOSTAR_XML_DESCRIPTION' );
}
}
// Default method:
jQuery.ajax( 'index.php?option=com_ajax&template=protostar&format=json' );
// Custom method:
jQuery.ajax( 'index.php?option=com_ajax&template=protostar&format=json&method=mySuperAwesomeMethodToTrigger' );
class tplHathorHelper
{
public static function getAjax()
{
return __METHOD__ . "\n\n" . JText::_( 'TPL_HATHOR_XML_DESCRIPTION' );
}
public static function mySuperAwesomeMethodToTriggerAjax()
{
return __METHOD__ . "\n\n" . JText::_( 'TPL_HATHOR_XML_DESCRIPTION' );
}
}
// Default method:
jQuery.ajax( 'index.php?option=com_ajax&template=hathor&format=json' );
// Custom method:
jQuery.ajax( 'index.php?option=com_ajax&template=hathor&format=json&method=mySuperAwesomeMethodToTrigger' );
Status | New | ⇒ | Pending |
Category | ⇒ | Administration Language & Strings Front End com_ajax |
Labels |
Added:
?
?
|
I wouldn't restrict it to the template of the current menuitem. I don't see a reason for that restriction. For modules we also only check for the published state and not if it's actually visible.
I would just check if the template is published.
Labels |
Added:
?
?
|
Done.
Is retrieving the template published state best accessed through JTable::getInstance('extension');
?
Since we don't seem to have a JTemplateHelper::isEnabled method (like we have for components, plugins and modules), I would probably just use a direct database query. But using the table should work as well.
Yeah, I did wonder whether it would be helpful to suggest creating a Template Helper as modules, plugins & languages all have their own helpers & classes.
I've used:
$table = JTable::getInstance('extension');
$templateid = $table->find(array('type' => 'template', 'element' => $template));
if ($templateid && $table->load($templateid) && $table->enabled)
...
For consistency it would make sense, yes. Not sure how useful it will be.
I have tested this item
Thanks for your effort and patience.
What's the next step for this feature? Do I need to run more tests or is it pending the next Joomla release?
Usually, we want two people testing a PR. Your own test will not count as we assume you tested your own code prior to submitting it
When those tests are done, it's the call of the release leader to include it into the next release. earliest possible release will be 3.8.0 since it is a new feature.
Okay, sure. Thanks for letting me know :)
I have tested this item
Status | Pending | ⇒ | Ready to Commit |
RTC after two successful tests.
It would be great.
@Grigory90 I'm not the release leader so I can't take the decision on that. Lets give Michael a bit time to decide on that.
Labels |
Added:
?
|
Status | Ready to Commit | ⇒ | Fixed in Code Base |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2017-08-20 15:57:14 |
Closed_By | ⇒ | mbabker |
When then is implemented the documentation will also need updating:
https://docs.joomla.org/Using_Joomla_Ajax_Interface