Forum Moderators: coopster

Message Too Old, No Replies

Integrate adsense code into a wiki using php

Hard to do, since wikis do not read javascript

         

chopin2256

9:18 pm on Aug 31, 2005 (gmt 0)

10+ Year Member



I am trying to get adsense to output into mediawiki, but this isn't so easy. Mediawiki doesn't read javascript. So, I created an extension. I have to put the code between these lines in order to get it to work:

-----------------------------------
$output = "

adsense code here

";
return $output;
-----------------------------------

Is it possible to get adsense to show by doing it this way? The reason why it has to be between the outputs is because this is how a mediawiki extension is created. So, ideally, I would want this to work:

$output = "

<script type=\"text/javascript\"><!--
google_ad_client = \"pub-7753904216505631\";
google_ad_width = 728;
google_ad_height = 90;
google_ad_format = \"728x90_as\";
google_ad_type = \"text_image\";
google_ad_channel =\"\";
google_color_border = \"F7DBBC\";
google_color_bg = \"F7DBBC\";
google_color_link = \"60442D\";
google_color_url = \"60442D\";
google_color_text = \"60442D\";
//--></script>
<script type=\"text/javascript\"
src=\"http://pagead2.googlesyndication.com/pagead/show_ads.js\">
</script>

";
return $output;

And this isn't working....no output...but I don't get errors. Can someone help?

chopin2256

5:09 am on Sep 1, 2005 (gmt 0)

10+ Year Member



Can anyone help me with getting this adsense code to work given these conditions? Should I rephrase my question?

jatar_k

3:49 pm on Sep 1, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



is this within a function? if so then the return is correct, if it isn't in a function then you should be using echo or some print function.

chopin2256

6:27 pm on Sep 1, 2005 (gmt 0)

10+ Year Member



Yes it is within a function:

<?php
$wgExtensionFunctions[] = "wfassExtension";
function wfassExtension() {
global $wgParser;
$wgParser->setHook( "adsensesearch", "renderass" );
}

function renderass( $input, $argv ) {
$output = '

--adsense code--

';
return $output;
}
?>

The above code I mentioned does not display the ads though.

chopin2256

8:03 pm on Sep 1, 2005 (gmt 0)

10+ Year Member



Solved.

Problem was that I had to get rid of the unecessary spaces, and the backslashes for some reason. The output prints out the exact string, which I failed to see until now.

jatar_k

8:24 pm on Sep 1, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



nicely done, I wouldn't have figurd that one