Router build function issue? #229

Closed
opened 2018-02-06 17:38:42 +00:00 by cpaschen · 10 comments
cpaschen commented 2018-02-06 17:38:42 +00:00 (Migrated from github.com)

Steps to reproduce the issue

Build a component following the latest hello world tutorial.
Including a front-end edit view.
In the front-end list site view add the following code to the PHP tab - "Add PHP (custom view script)" area:

  $canAdd = [[[Component]]]Helper::getActions('keyword_suggested',$items,'keyword_suggested');
  if ($canAdd ->get('keyword_suggested.create'))
  {
    $editItemNumber = 0;
    $addLink = '<a href="';
    $addLink.= JRoute::_('index.php?option=com_[[[component]]]&task=keyword_suggested.edit&id=0');

    $addLink.= '">';
    $addLink.= JText::_('Suggest a new Keyword');
    $addLink.= '</a>';
   }

Expected result

In the build function of the router.php it should have (around line 59):

	if (isset($query['view']))
	{
		$view = $query['view'];

        if (!empty($query['view']))
		{
			$segments[] = $query['view'];
		}

		unset($query['view']);
	}

Actual result

in the router.php (around line 59) it has:

	if (isset($query['view']))
	{
		$view = $query['view'];

		if (empty($query['Itemid']))
		{
			$segments[] = $query['view'];
		}

		unset($query['view']);
	}

This makes the add link not work properly when SEF is enabled on the site.

(And I don't see any way within JCB to change how that is generated Iwithout actually changing JCB code).

System information (as much as possible)

  • OS Name & Version: Windows 10 (WAMP)
  • MySql Version: 5.7.19
  • Apache Version: 2.4.27
  • PHP Version: 7.1.9
  • Joomla Version: 3.8.3
  • JCB Version: 2.6.13
  • Browser: Chrome (latest)

Additional comments

I'm not sure if this is a bug or if there is some other way to get this link to work with SEF via JCB.

Also, I'm still a bit new configuring router so I might be approaching this wrong, but the indicated change is the only way I can get the link to work with the SEF enabled.

### Steps to reproduce the issue Build a component following the latest hello world tutorial. Including a front-end edit view. In the front-end list site view add the following code to the PHP tab - "Add PHP (custom view script)" area: $canAdd = [[[Component]]]Helper::getActions('keyword_suggested',$items,'keyword_suggested'); if ($canAdd ->get('keyword_suggested.create')) { $editItemNumber = 0; $addLink = '<a href="'; $addLink.= JRoute::_('index.php?option=com_[[[component]]]&task=keyword_suggested.edit&id=0'); $addLink.= '">'; $addLink.= JText::_('Suggest a new Keyword'); $addLink.= '</a>'; } ### Expected result In the build function of the router.php it should have (around line 59): if (isset($query['view'])) { $view = $query['view']; if (!empty($query['view'])) { $segments[] = $query['view']; } unset($query['view']); } ### Actual result in the router.php (around line 59) it has: if (isset($query['view'])) { $view = $query['view']; if (empty($query['Itemid'])) { $segments[] = $query['view']; } unset($query['view']); } This makes the add link not work properly when SEF is enabled on the site. (And I don't see any way within JCB to change how that is generated Iwithout actually changing JCB code). ### System information (as much as possible) - OS Name & Version: Windows 10 (WAMP) - MySql Version: 5.7.19 - Apache Version: 2.4.27 - PHP Version: 7.1.9 - Joomla Version: 3.8.3 - JCB Version: 2.6.13 - Browser: Chrome (latest) ### Additional comments I'm not sure if this is a bug or if there is some other way to get this link to work with SEF via JCB. Also, I'm still a bit new configuring router so I might be approaching this wrong, but the indicated change is the only way I can get the link to work with the SEF enabled.
cpaschen commented 2018-02-06 18:11:15 +00:00 (Migrated from github.com)

BTW ... I should clarify that there were TWO changes in that one line:

if (empty($query['Itemid']))

Change 1:

'Itemid' --changed to--> 'view'

Change 2:

empty --changed to--> !empty

Both changes were required to make the link work.

BTW ... I should clarify that there were TWO changes in that one line: if (empty($query['Itemid'])) Change 1: 'Itemid' --changed to--> 'view' Change 2: empty --changed to--> !empty Both changes were required to make the link work.
ro-ot commented 2018-02-06 18:43:26 +00:00 (Migrated from github.com)

Hi have you watched this?

Hi have [you watched this](https://www.youtube.com/watch?v=hYycPLbaMos&index=52&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE)?
ro-ot commented 2018-02-06 18:51:54 +00:00 (Migrated from github.com)

We may need to also add so field to edit the build method, since that is the area you are speaking about right. You do realize that the $view value is being added on line 91 little lower down in the same method.

So the code is actually correct, but your link is not correct. You need to add a list view to the link!

If you follow the hello world tutorial you will see it has a view value, not just a task.

We may need to also add so field to edit the build method, since that is the area you are speaking about right. You do realize that the `$view` value is being added on line 91 little lower down in the same method. **So the code is actually correct, but your link is not correct. You need to add a list view to the link!** If you follow the hello world tutorial you will see it has a view value, not just a task.
ro-ot commented 2018-02-06 18:53:02 +00:00 (Migrated from github.com)
JRoute::_('index.php?option=com_[[[component]]]&view=YOUR_LISTVIEW&task=keyword_suggested.edit&id=0');
``` JRoute::_('index.php?option=com_[[[component]]]&view=YOUR_LISTVIEW&task=keyword_suggested.edit&id=0'); ```

Hi @cpaschen I thought you had this one figured out, guess not.

@ro-ot is correct you are missing a views name, and it should be a list view name, so that is a site_view that has a list query as the main get.

But yea we could also look at the option to target the build function with some custom scripting. But I must say it is not a straight forward issue, as we have lots of dynamic generated values in it that can not be know until the moment of compilation.

You can get the hello world JCB package and add it to you component to see the code and try and copy it. Follow this tutorial.

Hi @cpaschen I thought you had this one figured out, guess not. @ro-ot is correct you are missing a **views name**, and it should be a _list view name_, so that is a **site_view** that has a **list query** as the **main get**. But yea we could also look at the option to target the build function with some custom scripting. But I must say it is not a straight forward issue, as we have lots of dynamic generated values in it that can not be know until the moment of compilation. You can get the [hello world JCB package](https://github.com/vdm-io/JCB-Packages/raw/master/JCB_helloWorld.zip) and add it to you component to see the code and try and copy it. Follow [this tutorial](https://youtu.be/lkE0ZiSWufg).
cpaschen commented 2018-02-13 16:48:02 +00:00 (Migrated from github.com)

FYI ... I 'kinda' resolved this issue.
Adding the site_view (list) did not resolve the issue.
However, by using the custom code option I was able to just replace the code in the router and it is working now. Not sure exactly why, but I'll dig into the issue more as I create more edit forms with this and see what happens.

FYI ... I 'kinda' resolved this issue. Adding the site_view (list) did not resolve the issue. However, by using the custom code option I was able to just replace the code in the router and it is working now. Not sure exactly why, but I'll dig into the issue more as I create more edit forms with this and see what happens.

I am wondering how it can happen that a simple task as opening a edit view can become so dificult. I have done this a thousand times and never had any issues. I think it will be well worth my wile to have a Skype/Hangout call with you and some Teamviewer overview of your code and intend, to see where we are not on the same page. I am very sure this is a very small issue, that could be resolved very easy, if I can just understand and see what you are doing.

The hello world package has all the code and edit options as demonstrated during the video. How you can follow that example and not succeed is important to me, so I can try and improve the logical path and tutorials.

I am wondering how it can happen that a simple task as opening a edit view can become so dificult. I have done this a thousand times and never had any issues. I think it will be well worth my wile to have a Skype/Hangout call with you and some Teamviewer overview of your code and intend, to see where we are not on the same page. I am very sure this is a very small issue, that could be resolved very easy, if I can just understand and see what you are doing. The hello world package has all the code and edit options as demonstrated during the video. How you can follow that example and not succeed is important to me, so I can try and improve the logical path and tutorials.
cpaschen commented 2018-02-14 21:25:28 +00:00 (Migrated from github.com)

I'm not sure if a live connect would work due to time differences. But I've installed JCB and the component that I was working on on a live public test joomla install. I compiled and installed and got the same thing.

The strange thing is that I installed the Hello World package, compiled and installed and if I try to edit any entry (that I've created on the admin-side), I get the same issue - the system requires me to login to htaccess that is added to the admin side. And the link to ADD GREETING that I added (per the video and comments here) result in the same issue that I reported earlier.

I did create an 'add article' menu option and that worked. So there is definitely something working differently between JCB built code and the core content/article code that is causing a problem.

I can share super user login and ftp to the site if you'd like to go in and try to figure out what is going on. If that will work, please let me know where to send the info, or if you would prefer to just to the live connect, let me know your time zone and what time of day you would prefer and I'll see if I can make that work.

I'm not sure if a live connect would work due to time differences. But I've installed JCB and the component that I was working on on a live public test joomla install. I compiled and installed and got the same thing. The strange thing is that I installed the Hello World package, compiled and installed and if I try to edit any entry (that I've created on the admin-side), I get the same issue - the system requires me to login to htaccess that is added to the admin side. And the link to ADD GREETING that I added (per the video and comments here) result in the same issue that I reported earlier. I did create an 'add article' menu option and that worked. So there is definitely something working differently between JCB built code and the core content/article code that is causing a problem. I can share super user login and ftp to the site if you'd like to go in and try to figure out what is going on. If that will work, please let me know where to send the info, or if you would prefer to just to the live connect, let me know your time zone and what time of day you would prefer and I'll see if I can make that work.

I am sorry @cpaschen your .htaccess issue is not a bug or issue in JCB, but a custom adaptation. You are welcome to research the issue and give me solid feedback on exactly what needs to change and where. I mean exactly as this code in this file on that line must change from this to that. But I do not have the time to do that for you. I offered my time not realizing that it is your htaccess messing with the Joomla website.

I mean if your take away this htaccess all works right? and this means the the component works as expected. The fact the Joomla is posting is strange and it would be helpful to know why, but alas I do not have the time for that right now.

I am sorry @cpaschen your .htaccess issue is not a bug or issue in JCB, but a custom adaptation. You are welcome to research the issue and give me solid feedback on exactly what needs to change and where. I mean exactly as this code in this file on that line must change from this to that. But I do not have the time to do that for you. I offered my time not realizing that it is your htaccess messing with the Joomla website. I mean if your take away this htaccess all works right? and this means the the component works as expected. The fact the Joomla is posting is strange and it would be helpful to know why, but alas I do not have the time for that right now.
cpaschen commented 2018-02-14 23:13:26 +00:00 (Migrated from github.com)

Sorry, I 'mixed up' 2 issues. Although on the same site, the htaccess issue doesn't have any specific relation to the add link and router issue that this issue was originally addressing. I'll get back to that.

I've imported the hello world package, compiled and installed.
I've added an 'add greeting' link per video tutorial and the previous mentioned link.

The hello world Add Greeting link works - without any modification of the router file, but the one in my custom component does not.

The add links are almost identical with each other (other than the respective names for the views/tasks/etc).

So there is a problem somewhere else.

I do NOT expect you to track this down. I'll go through and compare the two components to see where the issue is. I'm guessing it is because some other step in setting it up within JCB did not get done correctly.
I'll keep working on this and once I find the issue I'll update this ticket and then I'll make sure my 'JCB Steps Checklist' is updated and post that to the wiki.

Sorry, I 'mixed up' 2 issues. Although on the same site, the htaccess issue doesn't have any specific relation to the add link and router issue that this issue was originally addressing. I'll get back to that. I've imported the hello world package, compiled and installed. I've added an 'add greeting' link per video tutorial and the previous mentioned link. The hello world Add Greeting link works - without any modification of the router file, but the one in my custom component does not. The add links are almost identical with each other (other than the respective names for the views/tasks/etc). So there is a problem somewhere else. I do NOT expect you to track this down. I'll go through and compare the two components to see where the issue is. I'm guessing it is because some other step in setting it up within JCB did not get done correctly. I'll keep working on this and once I find the issue I'll update this ticket and then I'll make sure my 'JCB Steps Checklist' is updated and post that to the wiki.
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#229
No description provided.