Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2007-01-01 18:40:36

konstantinos
New Member
Registered: 2007-01-01
Posts: 9

[textile] Adsense code comes out broken?

[I can’t tell if this forum applies to TxP+Textile users, or just Textile users in general. I’ve wrote it with TxP users in mind, but WP and other CMS users can certainly help as well.]

Assuming you want to add an Adsense unit from within the “Post” textarea. The code goes something like this:

===================
<script type=“text/javascript”><!—
google_ad_client = “pub-################”;
google_ad_width = 125;
google_ad_height = 125;
google_ad_format = “125×125_as”;
google_ad_type = “text”;
//###channel information goes here###
google_ad_channel = “##########”;
google_color_border = “6699CC”;
google_color_bg = “003366”;
google_color_link = “FFFFFF”;
google_color_text = “AECCEB”;
google_color_url = “AECCEB”;
//—></script>
<script type=“text/javascript”
src=“http://pagead2.googlesyndication.com/pagead/show_ads.js”>
</script>
===================

  • If you simply go ahead and paste it in the “Post” textarea, Textile will apply its usual typographic changes (curly quotes, etc.) and break the code right?
  • If you wrap the code within “notextile” or “==” tags, what will happen? (In WordPress, I get the code printed (i.e. not parsed). And if I wrap each line of the code with “==” tags all sorts of strange things happen.)

In short, my question would be: how do you get the Adsense code to be parsed as simple HTML?

I don’t use TxP; I use WordPress and want to see if this is an issue with Textile in general (this is where you come in), or with how Textile is implemented in the plugin I’m using in particular.

Thanks again for your help!

Last edited by konstantinos (2007-01-01 18:40:57)

Offline

#2 2007-01-01 20:56:17

zem
Developer Emeritus
From: Melbourne, Australia
Registered: 2004-04-08
Posts: 2,579

Re: [textile] Adsense code comes out broken?

Textile doesn’t understand Javascript syntax.

With Textpattern 4.0.4, you could do something like:

notextile. <script type=“text/javascript”><!—
...
</script>

Use a blank line to mark the end of the javascript.

But article bodies are for content, not code. The neat way of doing it is explained in the FAQ. If you want an adsense unit displayed with each article, you should consider putting the js code in your article form (perhaps with a tag like if_category or if_section to make it conditional).

Last edited by zem (2007-01-01 20:58:22)


Alex

Offline

#3 2007-01-01 23:38:07

konstantinos
New Member
Registered: 2007-01-01
Posts: 9

Re: [textile] Adsense code comes out broken?

Alex, thank you for the quick reply, I appreciate it. (And I see your point about the Post textarea being for content, not code; but this is the request of a client and I see his point too.)

I’ve tried prepending the first line of code with “notexile. “ (and left a blank line after </script>) but it doesn’t seem to work.

I’ve also tried writing the Adsense code in a separate file and including it from within the textarea with a PHP include command but the code stills get Textile’d…

If someone has got suggestions on how to work-around this please let me know!

There has to be a work-around…

Thanks!

Last edited by konstantinos (2007-01-01 23:38:49)

Offline

#4 2007-01-02 00:26:20

marios
Archived Plugin Author
Registered: 2005-03-12
Posts: 1,253

Re: [textile] Adsense code comes out broken?

konstantinos wrote:

If someone has got suggestions on how to work-around this please let me know!

There has to be a work-around…

That’s actually quite easy to do.
Just leave an emty line and a white-space character before the java-script code block and one empty line at the end, and you are all set.

Also, you could put the whole thing in a misc form, and then in your article you just call it up, using an output_form.
( leaving one white-space character again in front )
That way, you have it stored safely away from silly typos.

No need for PHP hackery.

regards, marios

Last edited by marios (2007-01-02 00:28:01)


⌃ ⇧ < ⌃ ⇧ >

Offline

#5 2007-01-02 00:27:26

zem
Developer Emeritus
From: Melbourne, Australia
Registered: 2004-04-08
Posts: 2,579

Re: [textile] Adsense code comes out broken?

“Doesn’t seem to work” could mean anything.

The suggestions above, and in the FAQ, all work with Textpattern 4.0.4. Try clicking on the “HTML” tab on the content > write page if you’re having trouble – it’ll show the raw HTML output of the article body.


Alex

Offline

#6 2007-01-02 01:39:42

hcgtv
Plugin Author
From: Key Largo, Florida
Registered: 2005-11-29
Posts: 2,722
Website

Re: [textile] Adsense code comes out broken?

Like marios said, I put my adsense code into a misc form and then call it from anywhere using output_form. I name the form according to the type of adsense ad – ads_160x600, etc. It’s working just fine for me, no errors to report.

<txp:output_form form="ads_160x600" />

Offline

#7 2007-01-03 21:56:45

konstantinos
New Member
Registered: 2007-01-01
Posts: 9

Re: [textile] Adsense code comes out broken?

Hello again, thank you everyone for your help and suggestions.

Unfortunately, it seems that none of them works in my case (remember, as I wrote in the first post, I use WordPress so some of the solutions couldn’t be applied directly).

zem wrote:

“Doesn’t seem to work” could mean anything.

I’ve compiled a list of all the solutions I’ve tried here — so you can see the results in action.

I would appreciate any suggestions you may have on how to work-around this.

(EDIT: Fixed wrong link.)

Last edited by konstantinos (2007-01-03 21:58:39)

Offline

#8 2007-01-03 22:10:30

marios
Archived Plugin Author
Registered: 2005-03-12
Posts: 1,253

Re: [textile] Adsense code comes out broken?

Did you consider to ask the plugin author ? That way you can solve the problem for all WP textile Users .
On TXP it’s working as expected.
If you would try it out, using Zem’s Textile Test section, you’d see it does.
May be it uses an older version of Textile.

regrds, marios


⌃ ⇧ < ⌃ ⇧ >

Offline

#9 2007-01-03 22:28:11

zem
Developer Emeritus
From: Melbourne, Australia
Registered: 2004-04-08
Posts: 2,579

Re: [textile] Adsense code comes out broken?

Just FYI, <script> tags are disabled in the online textile preview for obvious reasons. They’ll show up accurately in the XHTML source box, but not the browser Preview box.


Alex

Offline

#10 2007-01-03 22:36:17

konstantinos
New Member
Registered: 2007-01-01
Posts: 9

Re: [textile] Adsense code comes out broken?

marios wrote:

Did you consider to ask the plugin author ? That way you can solve the problem for all WP textile Users .

I did, still haven’t got a reply though. We’ll see.

If anyone can think of a hack to work-around this, let me know.

Thanks again!

Offline

#11 2007-01-04 20:01:33

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: [textile] Adsense code comes out broken?

If I were you, this is how I would do it:

1. Put the following inside a new misc type form named “adsense”…

<!-- start adsense -->
<script type="text/javascript">
<!--
google_ad_client = 'pub-################';
google_ad_width = 125;
google_ad_height = 125;
google_ad_format = '125x125_as';
google_ad_type = 'text';
google_ad_channel = '##########';
google_color_border = '6699cc';
google_color_bg = '003366';
google_color_link = 'ffffff';
google_color_text = 'aecceb';
google_color_url = 'aecceb';
//-->
</script>

<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<!-- end adsense -->

2. …and then call it from your article:

notextile. <txp:output_form form="adsense" />

Not only works, but saves needless typing. And what if you wanted to change it later? you’d have to go through every single article you used it in; this way you only have to update one form (though you could make as many different forms for as much variation as you like).

Offline

#12 2007-01-04 20:18:06

konstantinos
New Member
Registered: 2007-01-01
Posts: 9

Re: [textile] Adsense code comes out broken?

Yeah, but as I wrote, I don’t use TextPattern, I use WordPress!

(I appreciate the tip nonetheless!)

Offline

Board footer

Powered by FluxBB