Jscript - the old problem

Permalink
Hy to all.
I read allot of jscript and motool problems here But I have no answer for my problem yet.
I have to insert an affiliate banner on my page
( containing

<script type="text/javascript">
//<![CDATA[
var qsfJsHost = (("https:" == document.location.protocol) ? "https://www." : "http://");
document.write(unescape(...............
..............................//]]>
</script>

As usual , after inserting it, the site display the banner but the top editing tools it no longer exist..

I have not found solutions. and I have to leave concrete5..:(

Maybe you could tell me some ideas..

Regards,
dan

 
jbx replied on at Permalink Reply
jbx
There are usually only 2 things that can cause this error.
1) You have manually included jQuery somewhere in your theme. You don't need to do this, as it is already included by Concrete5.
2) There is an error somewhere in your JS that is breaking everything.

From that short snippet you have posted, it's difficult to tell what the issue is exactly.

Do you have a URL that I can look at? If not, then I highly recommend installing Firebug for Firefox and checking out the console. That will tell you where the Javascript Error is.

Jon
JohntheFish replied on at Permalink Reply
JohntheFish
In your php, try adding a condition so that the advert code is only included and displayed when you are not logged in. That way, visitors see the ads, but you see the edit bar and no ads.

Seehttp://www.concrete5.org/documentation/developers/permissions/users...
and
concrete/models/user.php

It will be something like (I have not run the code here):
$u = new User();
if (isobject($u) && $u->checkLogin() ){
  // do not render or show the ad stuff
} else {
  // banner ad code here
}


If there are other logins (such as online shoppers), then you may want to use a different test, such as
$u->isSuperUser()

Nevertheless, as jbx said, you should still look for and fix the script issue even if it is not locking up the edit bar any more.

PS. Just had a thought, if you are doing this with an HTML block, the php solution will be of no use to you. However, you could create a new view for the html block that includes the php above.
diasomie replied on at Permalink Reply
Thank you both.
Technical answers and I need to study them deeply.

For short:

1)The site is brand new, just installed and I inserted in a HTML block the affiliate link.
I cannot post the full code because I have some agreements with the script provider..It only miss an links and an apikey, as on Amazon api. Also it is NO possible to alter the script. Theer are some writed agreements.

some more ( I replaced some words with HHHHH):
<script type="text/javascript">
//<![CDATA[
var qsfJsoHost = (("https:" == document.location.protocol) ? "https://www." : "http://");
document.write(unescape("%3Cscript src='" + qsfJsoHost + "/HHHHHHHHHHHHHHHHHinit.js?v=1.0&key=NHHHHHHHHHHHHHHHH' type='text/javascript'%3E%3C/script%3E"));
//]]>
</script>


I will try to disable to see the script when I am logged in , but I have to test because his is an interactive banner, an search and the dimensions are very important. And I need to create an right sized block including the banner.

Here I let an temporary address where I made the test,http://www.bileteavion360.ro/index.php/about/...
Regards,
mkly replied on at Permalink Reply
mkly
I would very strongly suggest installing the Firebug addon for Firefox and turning it on. Click on the "console" tab and see if there is an error.
diasomie replied on at Permalink Reply
If I found correctly on firebug:

jQuery.fn.dialog is undefined
imgLoader.src = jQuery.fn.dialog.loaderImage;

and the second:

"NetworkError: 404 Not Found -http://www.xxx.ro/qsf/v2/qsf0Styles.css?key=... HHHHHHH template=classic_lat123"
mkly replied on at Permalink Reply
mkly
Ok, it looks like we are loading jQuery twice. I believe this is causing the error. I looked at the script and it loads
http://www.eskyservices.pl/qsf/v2/scripts/jquery-1.4.2.min.js

Concrete5 loads jQuery while a logged in user can edit a page. I'm not sure of the best way to handle this as it appears the script you are adding includes jQuery dynamically on page load.
JohntheFish replied on at Permalink Best Answer Reply
JohntheFish
In addition, dialog is in jQeury UI. However, C5 has its own dialog and a special build of jQuery UI that does not include the UI dialog.

So a double include of jQuery has broken it, but if/when you fix that I suspect your ad will then include jquery UI and cause more problems when C5 is in edit mode.

Your best bet from here is to put the ad within an iframe, so that it is sandboxed from the rest of your page.

I think you should put your code for the ad, including html and script, into a separate file, as if it were a complete small static html & script page. Then use your HTML block to create an iframe (or there is a C5 iFrame block), and load the separate ad file into that ifarme.

For robustness and security, you may want to keep that file under a different domain name. An iframe loaded from a different domain will make the browser prevent any cross-scripting between the iframe and the hosting page.
diasomie replied on at Permalink Reply
You guys are wonderful. Thank you.
I will read closely your answers to apply to my site. I will keep you informed if I succeeded or not.
Thank you again.
Dan.
diasomie replied on at Permalink Reply
PROBLEMS:

I followed the advices regarding the use of an Iframe addon and an html file and I succeeded to insert and the tool bar is available.
I use the "dynamic_iframe" addon.free

BUT
Problem is that I have to link to an file placed an the same domain. This is the condition of the addon. The addon inserted the banner but gived me error when I cliked the refferal link :
Error url is not on the same domain

I have to find another addon.
Anyway the method is working . All I have to do is to twek it ..
Thank you . I will post the results of the work.
JohntheFish replied on at Permalink Reply
JohntheFish
It may be that the referral link is trying to load a new page inside the iframe.

Inside the link, try changing it to have a target that replaces the whole page or opens in a new window.
<a href="http://whatever.the.referel.link.is" target="_top">

or
<a href="http://whatever.the.referel.link.is" target="_blank">


(See http://www.w3schools.com/tags/att_link_target.asp... )