? ?

User tests: Successful: Unsuccessful:

avatar jo-sf
jo-sf
19 Sep 2014

Suppose you have a Joomla website that is reachable via different domain names or via HTTP and HTTPS. If you want to use the links A/B/C in your articles (I assume that your template knows what to do with these, which is the case e.g. with the Beez 5 template) you currently have to decide which of your domain names you want to use resp. whether you want to use HTTP or HTTPS as protocol if you want to assign links to other pages within your website to the links A/B/C.

This PR proposes changes which allow to assign internal links to the links A/B/C.

About testing these changes:

  • it is possible to assign to the links A/B/C both in the backend and in the frontend, but for the frontend it must be enabled first in the options menu of the article manager
  • there are four cases to be considered in testing:
    • Joomla is installed in the document root of your webserver
      • SEO URL rewriting is not active (means: all server relative paths start with "index.php")
      • SEO URL rewriting is active
    • Joomla is installed in a subdirectory of the document root of your webserver
      • SEO URL rewriting is not active (means: all server relative paths start with the subdirectory followed by "index.php")
      • SEO URL rewriting is active

For testing I used the fruit shop welcome page from the example installation but any other pages should work as well. I added links to the "Apples", "Bananas" and "Tamarind" pages to the "Welcome" page of the fruit shop.

What should work with these changes (and what not) - examples based upon the fruit shop pages:

  • document root installation, no URL rewriting
    • index.php/fruit-encyclopedia/38-a => /index.php/fruit-encyclopedia/38-a
    • /index.php/fruit-encyclopedia/38-a => will not be changed
    • http://<ServerName>/index.php/fruit-encyclopedia/38-a => will not be changed
  • document root installation, URL rewriting
    • fruit-encyclopedia/38-a.html => /fruit-encyclopedia/38-a.html
    • /fruit-encyclopedia/38-a.html => will not be changed
    • http://<ServerName>/fruit-encyclopedia/38-a.html => will not be changed
  • subdirectory installation (j25/), no URL rewriting
    • index.php/fruit-encyclopedia/38-a => /j25/index.php/fruit-encyclopedia/38-a
    • j25/index.php/fruit-encyclopedia/38-a => /j25/j25/index.php/fruit-encyclopedia/38-a (wrong!)
    • /j25/index.php/fruit-encyclopedia/38-a => will not be changed
    • http://<ServerName>/j25/index.php/fruit-encyclopedia/38-a => will not be changed
  • subdirectory installation (j25/), URL rewriting
    • fruit-encyclopedia/38-a.html => /j25/fruit-encyclopedia/38-a.html
    • j25/fruit-encyclopedia/38-a.html => /j25/j25/fruit-encyclopedia/38-a.html (wrong!)
    • /j25/fruit-encyclopedia/38-a.html => will not be changed
    • http://<ServerName>/j25/fruit-encyclopedia/38-a.html => will not be changed

I know that there are other components in Joomla which also allow to enter URLs,e.g. the contact manager. It is probably also in those components of interest to allow internal URLs beside the external URLs currently only allowed there. If you enter a relative URL (means: URL without protocol etc.) the library routines do their best to convert this URL into an external URL (see libraries(joomla/form/form.php for details) but by principle it cannot work well always though I found an error in this part and corrected it as part of my changes.

avatar jo-sf jo-sf - open - 19 Sep 2014
avatar jissues-bot jissues-bot - change - 19 Sep 2014
Labels Added: ?
avatar zero-24
zero-24 - comment - 19 Sep 2014

@jo-sf are you sure to send a new feature against the 2.5.x branche?

avatar jo-sf
jo-sf - comment - 19 Sep 2014

@zero-24 yes I am, but as you've probably already seen I sent the same enhancement for the staging branch as well. Reason for sending it against the 2.5.x branch is that I think this branch will stay around for while (yes I know about the deadline December 31, 2014) and these changes come from my installation where I have to take care every time I'm doing an update that they don't get lost - and if these changes are part of the next patch I do no longer need to take care of it.

This comment was created with the J!Tracker Application at http://issues.joomla.org/.

avatar zero-24
zero-24 - comment - 19 Sep 2014

yes I am, but as you've probably already seen I sent the same enhancement for the staging branch as well.

Oh sorry i have not see it ;)

This comment was created with the J!Tracker Application at http://issues.joomla.org/.

avatar betweenbrain
betweenbrain - comment - 19 Sep 2014

Can you provide testing instructions? I'm not entirely clear on how this is being used.

avatar jo-sf
jo-sf - comment - 19 Sep 2014

If you have the example pages installed you might open the article "Fruit Shop" with the article manager. After doing so you find on the right side the section "Images and links" which you must open in order to add the links A, B and C to this article (by default the first section "Publishing options" is open).

There are three fields for each of the three links: the first one for the URL, the second for the text that will be displayed as link with the URL as target and the third controls whether the URL is opened in the same browser window, in a new one, as a popup window or as a modal window. Best is to leave the third field as it is ("Use global").

In my test instructions above I used the three pages "Apples", "Bananas" and "Tamarind" you find in the Fruit Encyclopedia of the Fruit Shop as targets for the links. Feel free to use any other article where you add the links A, B and C, and naturally you might also use any other up to three pages as targets for these links.

By default (means: with the current Joomla 2.5 code) you might only add complete URLs consisting of a protocol (http), a server name, a path and optionally a query and/or a fragment in the three URL fields. This is also stated in the tooltip for these three fields. If you enter anything else, like a server-internal path (/index.php/fruit-encyclopedia/38-a/6-apples), you'll get an error when saving the article.

After applying the patches for the six files in this PR you should be able to enter server-internal paths into those three URL fields, and they should be saved with the rest of the article. In case that the relative URL entered in one of these fields doesn't start with "/" the modified Joomla code tries to convert it into a server-internal path starting with a "/" (which will not always lead to the expected result but it works in most cases). But the modified code will not try to convert the given relative URL into a complete URL, with one exception: if it finds the name of the server at the beginning of the URL it will prepend the URL with the protocol ("http://"). This is (I think) due to the fact that some browsers don't show the protocol in the address field if the protocol is "http", and if the user copies the target URL from the address field of the browser the protocol is missing (and will be added by the Joomla code if the string at the beginning of the URL is the name of the current server).

After having saved the article with server-internal links in at least one of the fields link A, B or C and a text for the link to click at open this article in the frontend. With the default template ("Beez 5", if you use the Fruit Shop example pages) these links are displayed on top of the article. Clicking upon them shall lead you to the referenced page, but more interesting is the source code of the web page. Search there for the link text and check whether the URL left to this link text is a complete URL or an URL starting with a "/".

After applying my patches and when entering server-internal URLs into the link fields these URLs should start with a "/" such that the browser automatically uses the protocol and the server name of the referring page (means: the page you're currently looking at or at its source code).

I hope these instructions are clear enough for testing the behaviour of the Joomla 2.5 code prior and after applying my patches. If not feel free to ask again.

This comment was created with the J!Tracker Application at http://issues.joomla.org/.

avatar infograf768 infograf768 - change - 20 Sep 2014
Labels Added: ?
avatar infograf768
infograf768 - comment - 20 Sep 2014

I doubt about adding any new feature in 2.5.x. at this stage.

avatar infograf768
infograf768 - comment - 20 Sep 2014
avatar jo-sf
jo-sf - comment - 20 Sep 2014

@infograf768 I removed the superfluous brace at line 82 in the file url.php

This comment was created with the J!Tracker Application at http://issues.joomla.org/.

avatar Bakual
Bakual - comment - 20 Sep 2014

I'm not in favor of adding things like that to 2.5.

Reason for sending it against the 2.5.x branch is that I think this branch will stay around for while

End of life is in 3 months and by then everyone should have upgraded to Joomla 3.

The branch may stay available for archive purposes, but it will not accept a single commit after 2014-12-31. And obviously there will be no release anymore next year.

avatar infograf768
infograf768 - comment - 21 Sep 2014

but by principle it cannot work well always though I found an error in this part and corrected it as part of my changes.

If you have seen an error though, please create a new tracker for that one only.

avatar jo-sf
jo-sf - comment - 22 Sep 2014

@infograf768
I created PR #4321 for the error I've found in libraries/joomla/form/form.php.

This comment was created with the J!Tracker Application at http://issues.joomla.org/.

avatar infograf768
infograf768 - comment - 22 Sep 2014

4321 works fine. Closing this one.

avatar infograf768 infograf768 - close - 22 Sep 2014
avatar infograf768 infograf768 - change - 22 Sep 2014
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2014-09-22 09:14:41

Add a Comment

Login with GitHub to post a comment