Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-06-06 11:07:47

Skubidu
Archived Plugin Author
Registered: 2004-10-23
Posts: 611
Website

Plugin development: gps('file') and $thisarticle

Hi!

I’ve got an registrations form on one of my sites. There is some JavaScript needed for this form and I call it with <script type="text/javascript" src="http://www.my.site/?file=dgd24-anmeldung"></script> and the following code in a plugin:

if(gps('file') = = 'dgd24-anmeldung') {
  echo 'alert("Hello World");';
}

The form is avaiable in different languages so I’ve got an other plugin with all my language strings an the function dgdTxt($what, $lang) to call these strings. So my script looks like this:

if(gps('file') = = 'dgd24-anmeldung') {
  echo 'alert("'.dgdTxt('HelloWorld', $lang).'");';
}

The variable $lang should be the exactly what’s in $thisarticle['url-title']. So I tried:

if(gps('file') = = 'dgd24-anmeldung') {
  global $thisarticle;
  echo 'alert("'.dgdTxt('HelloWorld', $thisarticle['url-title']).'");';
}

But $thisarticle seems not to be populated yet. So I tried to use $pretext:

if(gps('file') = = 'dgd24-anmeldung') {
  require_once('textpattern/config.php');
  require_once('textpattern/lib/txplib_db.php');
  global $pretext;
  $lang = fetch('url_title','textpattern','id',$pretext['id'],$debug='');	
  echo 'alert("'.dgdTxt('HelloWorld', $lang.'");';
}

It does simply not work.
Am I stupid or isn’t there a chance to get the url title anyhow if I try to call JavaScript via gps('file')?
Please help me!

Thank,
Nils

PS: All = = should be == (Textile didn’t like it that way)

Offline

#2 2006-06-06 13:30:06

Skubidu
Archived Plugin Author
Registered: 2004-10-23
Posts: 611
Website

Re: Plugin development: gps('file') and $thisarticle

Problem solved :)
Bastian sent me an idea via email that worked like a charm:
I just created a tag that is called in an article form that inserts the JavaScript call adding &lang=... at the end of the link.

Thanks, Bastian!

Last edited by Skubidu (2006-06-06 13:30:29)

Offline

Board footer

Powered by FluxBB