? ? ? ? ? Pending

User tests: Successful: Unsuccessful:

avatar bassmanpaul
bassmanpaul
5 Jun 2017

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.

Front end test:

templates/protostar/helper.php:

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' );
	}
}

Ajax call test:

// 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' );

Expected results:

  • When called from the front end in protostar template: ✔ success.
  • When called from the front end in another template: ✖ unauthorised.
  • When called from the back end in any template: ✔ success.

Back end admin test:

templates/hathor/helper.php:

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' );
	}
}

Ajax call test:

// 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' );

Expected results:

  • When called from the front end in any template: ✖ unauthorised.
  • When called from the back end in any template: ✔ success.
avatar bassmanpaul bassmanpaul - open - 5 Jun 2017
avatar bassmanpaul bassmanpaul - change - 5 Jun 2017
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 5 Jun 2017
Category Administration Language & Strings Front End com_ajax
avatar bassmanpaul bassmanpaul - change - 5 Jun 2017
Labels Added: ? ?
avatar bassmanpaul
bassmanpaul - comment - 5 Jun 2017

When then is implemented the documentation will also need updating:

https://docs.joomla.org/Using_Joomla_Ajax_Interface

avatar Bakual
Bakual - comment - 5 Jun 2017

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.

avatar bassmanpaul bassmanpaul - change - 6 Jun 2017
Labels Added: ? ?
avatar bassmanpaul
bassmanpaul - comment - 6 Jun 2017

Done.

Is retrieving the template published state best accessed through JTable::getInstance('extension');?

avatar Bakual
Bakual - comment - 6 Jun 2017

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.

avatar bassmanpaul
bassmanpaul - comment - 6 Jun 2017

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)
...
avatar Bakual
Bakual - comment - 6 Jun 2017

For consistency it would make sense, yes. Not sure how useful it will be.

avatar matrikular
matrikular - comment - 6 Jun 2017

I have tested this item successfully on 8bbf94d


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/16532.

Thanks for your effort and patience.

avatar matrikular matrikular - test_item - 6 Jun 2017 - Tested successfully
avatar bassmanpaul
bassmanpaul - comment - 9 Jun 2017

What's the next step for this feature? Do I need to run more tests or is it pending the next Joomla release?

avatar Bakual
Bakual - comment - 9 Jun 2017

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.

avatar bassmanpaul
bassmanpaul - comment - 9 Jun 2017

Okay, sure. Thanks for letting me know :)

avatar Grigory90 Grigory90 - test_item - 19 Aug 2017 - Tested successfully
avatar Grigory90
Grigory90 - comment - 19 Aug 2017

I have tested this item successfully on 8bbf94d


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/16532.

avatar franz-wohlkoenig franz-wohlkoenig - change - 19 Aug 2017
Status Pending Ready to Commit
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 19 Aug 2017

RTC after two successful tests.

avatar zero-24
zero-24 - comment - 19 Aug 2017

@mbabker do you want to have this in 3.8?

avatar Grigory90
Grigory90 - comment - 19 Aug 2017

@zero-24 It would be great.

avatar zero-24
zero-24 - comment - 19 Aug 2017

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.

avatar mbabker mbabker - change - 20 Aug 2017
Labels Added: ?
avatar mbabker mbabker - change - 20 Aug 2017
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
avatar mbabker mbabker - close - 20 Aug 2017
avatar mbabker mbabker - merge - 20 Aug 2017

Add a Comment

Login with GitHub to post a comment