Unable to put custom button on front end view #338

Closed
opened 2018-09-10 13:54:22 +00:00 by peterpetrov · 12 comments
peterpetrov commented 2018-09-10 13:54:22 +00:00 (Migrated from github.com)

Steps to reproduce the issue

Created front view and added custom button to it that redirects to external address. The idea is to test the custom button functionality.
Target Controller Method: redirectExternal
Target: Both
Type: Default

PHP (controller methods):

public function redirectExternal() {

header("Location: https://www.google.bg/search?q=how+to+get+pregnant&oq=how+to+get+preg&aqs=chrome.0.0j69i57j0l4.6736j0j8&sourceid=chrome&ie=UTF-8"); /* Redirect browser */
exit();
}

Expected result

When clicking the button to redirect to the link

Actual result

Printing error that there is no function. When i enable the debug this is on line 123 which says:

123: if ($this->canDo->get('buttons.test_redirection'))

If i comment it out plus the if brackets and leave this code only:

                    JToolBarHelper::custom('buttons.redirectExternal', 'joomla', '', 'COM_TEST_COMPONENT_TEST_REDIRECTION', false);

i am getting then javascript errors and the command is not executed.

System information (as much as possible)
OS Name & Version: Centos 7.4
MySql Version: MariaDB 10
Apache Version: Nginx 1.12
PHP Version: 7.3
Joomla Version: 3.8.12
JCB Version: 2.9.0
Browser: Chrome

Additional comments

### Steps to reproduce the issue Created front view and added custom button to it that redirects to external address. The idea is to test the custom button functionality. Target Controller Method: redirectExternal Target: Both Type: Default PHP (controller methods): ``` public function redirectExternal() { header("Location: https://www.google.bg/search?q=how+to+get+pregnant&oq=how+to+get+preg&aqs=chrome.0.0j69i57j0l4.6736j0j8&sourceid=chrome&ie=UTF-8"); /* Redirect browser */ exit(); } ``` ### Expected result When clicking the button to redirect to the link ### Actual result Printing error that there is no function. When i enable the debug this is on line 123 which says: 123: if ($this->canDo->get('buttons.test_redirection')) If i comment it out plus the if brackets and leave this code only: JToolBarHelper::custom('buttons.redirectExternal', 'joomla', '', 'COM_TEST_COMPONENT_TEST_REDIRECTION', false); i am getting then javascript errors and the command is not executed. System information (as much as possible) OS Name & Version: Centos 7.4 MySql Version: MariaDB 10 Apache Version: Nginx 1.12 PHP Version: 7.3 Joomla Version: 3.8.12 JCB Version: 2.9.0 Browser: Chrome ### Additional comments

Did you try it with only function?

Did you try it with **only function**?
peterpetrov commented 2018-09-11 07:38:41 +00:00 (Migrated from github.com)

I have just now. Result is the same.

Peter

I have just now. Result is the same. Peter

Can you give me a screenshot of the tab inside the site view, where you have all this setup?

Can you give me a screenshot of the tab inside the site view, where you have all this setup?
peterpetrov commented 2018-09-11 10:42:15 +00:00 (Migrated from github.com)

screen shot 2018-09-11 at 13 41 23
screen shot 2018-09-11 at 13 41 00

![screen shot 2018-09-11 at 13 41 23](https://user-images.githubusercontent.com/2786810/45355210-7bce3b80-b5c8-11e8-808c-be177c743102.png) ![screen shot 2018-09-11 at 13 41 00](https://user-images.githubusercontent.com/2786810/45355211-7bce3b80-b5c8-11e8-92c6-ebab55c1b196.png)

Does the page load without the button?

Does the page load without the button?
peterpetrov commented 2018-09-11 11:24:35 +00:00 (Migrated from github.com)

yes it does, i can give you access to the site. Just please use the test view only because the MR project is under active development for production in the the next 2 weeks or so and i don't have backup of it.

yes it does, i can give you access to the site. Just please use the test view only because the MR project is under active development for production in the the next 2 weeks or so and i don't have backup of it.

No I don't want access... best keep this simple. I will run more test on my end, and get back to you.

No I don't want access... best keep this simple. I will run more test on my end, and get back to you.
peterpetrov commented 2018-09-11 11:30:46 +00:00 (Migrated from github.com)

OK thanks. Let me know if i can assist in the testing additionally.

OK thanks. Let me know if i can assist in the testing additionally.
ro-ot commented 2018-09-11 13:19:50 +00:00 (Migrated from github.com)

Found the issue, seems Joomla change this area considerably (since the time we used it) so we will need to adapt JCB.

TODO:

  • Load the Joomla framework with (JHtml::_('behavior.framework', true);)
  • Add a custom submit script for the button, that does not attempt validation
  • Add the php $this->canDo->get(...) values to the page
  • Add a form to the page with a form token for safety
  • Checks to not do any of the above if the developer already added them manually
Found the issue, seems Joomla change this area considerably (since the time we used it) so we will need to adapt JCB. TODO: - Load the Joomla framework with (`JHtml::_('behavior.framework', true);`) - Add a custom submit script for the button, that does not attempt validation - Add the php `$this->canDo->get(...)` values to the page - Add a form to the page with a form token for safety - Checks to not do any of the above if the developer already added them manually
peterpetrov commented 2018-09-11 13:24:41 +00:00 (Migrated from github.com)

Thanks. Let me know if there is anything i can do to assist. Not sure i can write core JCB yet but still.

Thanks. Let me know if there is anything i can do to assist. Not sure i can write core JCB yet but still.

I have just pushed the fix, please test the staging branch, and remember the button has permissions.

I have just pushed the fix, please test the [staging branch](https://github.com/vdm-io/Joomla-Component-Builder/commit/5962b557c8244472c6637a2713978640472e8d36), and remember the button has permissions.
peterpetrov commented 2018-09-12 13:03:58 +00:00 (Migrated from github.com)

I can confirm that it works. I will start doing some more tests for what kind of functions I need to implement and let you know if anything pops up.

Thank you very much!

Peter

I can confirm that it works. I will start doing some more tests for what kind of functions I need to implement and let you know if anything pops up. Thank you very much! Peter
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: joomla/Component-Builder#338
No description provided.