[SOLVED] TinyMCE stripping out domain name (https://example.com/)

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Locked
10010110

[SOLVED] TinyMCE stripping out domain name (https://example.com/)

Post by 10010110 »

When putting a link to a secure page I noticed that whatever I do TinyMCE seems to strip out the prefix of the domain including the domain itself, i.e. if I put https://example.com/test/blah.html it removes everything before test/blah.html. It may happen with reggular URLs, too, but I haven’t tried this. Is this a bug or a feature? And if yes how can I disable that so it writes the complete URL?
Last edited by 10010110 on Thu Jan 03, 2008 6:11 pm, edited 1 time in total.
hexdj
Power Poster
Power Poster
Posts: 415
Joined: Sat Mar 24, 2007 8:28 am

Re: TinyMCE stripping out domain name (https://example.com/)

Post by hexdj »

Hi Binary Number  ;D

If I understand correctly you want to be able to switch between HTTPS to HTTP and viceversa? Is this why you want to enter the absolute URL in TinyMCE?
Last edited by hexdj on Thu Jan 03, 2008 12:52 am, edited 1 time in total.
10010110

Re: TinyMCE stripping out domain name (https://example.com/)

Post by 10010110 »

Thanks for your prompt replies.

hexdj: Yes, I have a regular site and have setup an aMember application (commercial membership software) where the signup is done on a secure page, hence I want a link from the home page to that secure signup page. However, after playing around a little bit, I found that absolute URLs that direct to other domains are working, only if I put an absolute URL directing to another page on this same domain the domain get stripped out by TinyMCE.

I don’t wanna put the actual domain here so say I have the site on http://example.com. If I put a link like link there is no problem but if I put link (i.e. the same domain as my site) and then view the HTML output in TinyMCE it shows link, i.e. it converted the link to a relative one. This happens with both, http and https protocol URLs.

mark: I’ve looked through the TinyMCE settings in the admin panel but there is nothing to set it. However, I’ve browsed the TinMCE documentation and I think I’ve found something. The FAQ states something and the Wiki states that something must be changed in the configuration.

OK, while typing the post here I’ve researched and played around more and this actually is a feature. According to the TinyMCE documentation the URL conversion is set to “true” by default and one has to disable it manually in the configuration file. So in case anybody else is running into this:

Go into your /modules directory and access the /TinyMCE directory where you have installed the TinyMCE module. There edit the file tinyconfig.php, search for the line that reads relative_urls : "true" (line 101 in version 2.2.5 of the TinyMCE basic module) and set it to “false”. That should be it.

Kinda stupid to enable it by default in my opinion…

Thanks for your help guys. :)
hexdj
Power Poster
Power Poster
Posts: 415
Joined: Sat Mar 24, 2007 8:28 am

Re: [SOLVED] TinyMCE stripping out domain name (https://example.com/)

Post by hexdj »

I was about to post my solution but since you found a way to do it, great!.

In my approach I have a few pages which are meant to be secure, so I assign a variable to each page in their metadata and thru a UDT the page automatically switches to secure, or non-secure. This is useful, if you have let's say a menu and don't want to bother with giving absolute paths thru TinyMCE, you can simply give the CMS_Self Link and the page itself will do the rest.

Let me know if you're still interested and I'll post the code for it.
10010110

Re: [SOLVED] TinyMCE stripping out domain name (https://example.com/)

Post by 10010110 »

Yeah, go ahead and post your code. I’ll check it out and see if it’s something for me. But others might be interested in this as well…
So you could also post your solution in the documentation.
hexdj
Power Poster
Power Poster
Posts: 415
Joined: Sat Mar 24, 2007 8:28 am

Re: [SOLVED] TinyMCE stripping out domain name (https://example.com/)

Post by hexdj »

Alright here it goes

I have two UDTs, first one is called https

Code: Select all

if(empty($_SERVER['HTTPS']))
{
    $newurl = 'https://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
    header("location: $newurl");
    exit();
}
This one is http

Code: Select all

if(!empty($_SERVER['HTTPS']))
{
    $newurl = 'http://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
    header("location: $newurl");
    exit();
}
Now in the pages are meant to be secure I have added the following in the Options Tab > Metadata for those pages

Code: Select all

{assign var='secure' value='1'}
You don't need to add anything to non-secure pages

And finally in my template added the following in the head section:

Code: Select all

{if isset($secure)}
  {https}
{else}
  {http}
{/if}
That's it, now whenever you have to link to a secure page within your site you don't have to worry about absolute paths (i.e. https://www.mysite.com/store/items/so/and/so) you can even use CMS_Self_Links directly from TinyMCE and it will redirect you to your secure page.

Note: Another problem with using absolute links is that if people click on your link they're taken to the secure page but if they navigate away to a page that is supposed to be non-secure your browser will keep the HTTPS:// in the address bar, which to me seems unnecesary if it's not meant to be secure. Just my thoughts.

Alternative Method For Secure Pages
instead of assigining a value of 1 to the variable "secure" in all your secure pages, you can use the smarty variable $page_alias and edit your template like this

Code: Select all

{if ($page_alias=="orders")}
  {https}
{elseif ($page_alias=="tickets")}
  {https}
{else}
  {http}
{/if}
Add as many {elseif} statements as the number of secure pages in your site. And use the page alias for each of those pages. This way you don't have to add the variable assign stuff to the metadata of each of your secure pages, you only have to edit your template.
Last edited by hexdj on Sat Jan 12, 2008 10:27 am, edited 1 time in total.
heatherfeuer

Re: [SOLVED] TinyMCE stripping out domain name (https://example.com/)

Post by heatherfeuer »

THANK YOU! THANK YOU! THANK YOU!!  :D :D :D
heatherfeuer

Re: [SOLVED] TinyMCE stripping out domain name (https://example.com/)

Post by heatherfeuer »

THANK YOU! THANK YOU! THANK YOU!!  :D :D :D

I have been trying to get this solved for what seems like forever! I was able to get https to work on the pages I wanted to secure, but I couldn't figure out how to return back to http for the non-secure pages. Your explanation was simple, straight-forward and was simple to implement. I tried the instructions in the documentation, but they didn't work for me. Your instructions did. Kudos and if I could increase your Karma by multitudes I would!
hexdj
Power Poster
Power Poster
Posts: 415
Joined: Sat Mar 24, 2007 8:28 am

Re: [SOLVED] TinyMCE stripping out domain name (https://example.com/)

Post by hexdj »

@heather:

Glad you found this useful  :D
Locked

Return to “CMSMS Core”