Page 1 of 2

modifying static pages-output and/or wrapURL-output

Posted: Fri Jun 16, 2006 12:43 pm
by thunder.x
Hi!
I´m using serendipity for a few months now and really fond of the 1.1 snapshot!
I´m currently using snapshot 1154 2006-04-25 08:15:11.
WrapURL 0.2
Statische Seiten (static pages) 3.35

there are a few other plugins around but I think they don´t need to be mentioned for my question.

before i forget it: I tried using "Externe PHP Anwendung 1.2" (external PHP-application) but it doesn´t even give me output at all.

Here an explanation of what I´m trying to do:
Embedding coppermine (1.48) in serendipity using static pages.
I don´t need complete embedding (like adapting design)!
So far it works by using wrapURL and then bind the wrapURL with static pages. But the iframe is bothering me because i want the iframe to dynamically fit the content so that I don´t have multiple scrollbars.

I searched the web for a solution and found something:
A javascript that does the work for me. I only need to modify the header and bodytag of the html-file but with my nearly nonexistent php-skills it´s a thing impossible for me to do. I don´t know where the static pages or wrapURL pages are located so I think they are newly generated everytime someone needs this or that static page or wrapURL.

Now the question: how can I modify the static pages or wrapURl output to insert the javascript and body-tag I need?

After some more thinking I come to the conclusion that it might be better just to modify wrapURL because I just have one URL wrapped but need more than one static page.

If there is more info required please feel free to ask.
I´m deeply grateful for any help there might be!

P.S. i tried to follow the tutorial here: http://www.s9y.org/forums/viewtopic.php?p=2321#2321
but wasn´t able to do this

Re: modifying static pages-output and/or wrapURL-output

Posted: Fri Jun 16, 2006 1:15 pm
by garvinhicking
Hi!

The body tag is not created by the staticpage or wrapurl plugin; it uses the body tag of the "index.tpl" main template file.

What exactly would you need to insert there? If it's all about the "onload", you can use your javascript without needing to modify the <body> tag, because javascript can add load events to your queue with this code anywhere in your page:

Code: Select all

<script type="text/javascript">
        function custom_addLoadEvent(func) {
          var oldonload = window.onload;
          if (typeof window.onload != 'function') {
            window.onload = func;
          } else {
            window.onload = function() {
              oldonload();
              func();
            }
          }
        }
custom_addLoadEvent(yourMagicFunctionName);
</script>

HTH,
Garvin

Posted: Fri Jun 16, 2006 2:06 pm
by thunder.x
first of all thx for the quick response! :)

here is what i intended to add:

Code: Select all

<script type="text/javascript">
<!--
function resize_me(n)
{
    d=5;ifObj=document.getElementsByName(n)[0];p=(document.all)?'scroll':'offset';
    eval("ifObj.style.width=window.frames[n].document.getElementsByTagName('body')[0]."+p+"Width+"+d);
    eval("ifObj.style.height=window.frames[n].document.getElementsByTagName('body')[0]."+p+"Height+"+d);
}
//-->
</script>
this would go into the header and then to modify the body tag:

Code: Select all

<body onload="parent.resize_me('ifr')">
tbh I don´t really know what your code and what the code i found really does but it seems to work well if i add it to a html-file.

but if i get you right i just need to modify my code to the following:

Code: Select all

<script type="text/javascript">
<!--
function custom_addLoadEvent(func) {
          var oldonload = window.onload;
          if (typeof window.onload != 'function') {
            window.onload = func;
          } else {
            window.onload = function() {
              oldonload();
              func();
            }
          }
        } 
function resize_me(n)
{
    d=5;ifObj=document.getElementsByName(n)[0];p=(document.all)?'scroll':'offset';
    eval("ifObj.style.width=window.frames[n].document.getElementsByTagName('body')[0]."+p+"Width+"+d);
    eval("ifObj.style.height=window.frames[n].document.getElementsByTagName('body')[0]."+p+"Height+"+d);
}
//-->
custom_addLoadEvent(resize_me);
</script>
did i get this correct?
sorry if this is a bit off-topic but what does your script there do? is it just to call a function that already exists? if no then i got it all wrong and my code prolly won´t work ;)

and again after a little bit of thinking:
does your script replace this bodytag-thingy ?

Posted: Fri Jun 16, 2006 3:58 pm
by garvinhicking
Hi!

You cannot pass a parameter to the addloadevent function, thus you would need to use this:

Code: Select all

<script type="text/javascript">
<!--
function custom_addLoadEvent(func) {
          var oldonload = window.onload;
          if (typeof window.onload != 'function') {
            window.onload = func;
          } else {
            window.onload = function() {
              oldonload();
              func();
            }
          }
        }
function resize_me()
{
    n = 'ifr';
d=5;ifObj=document.getElementsByName(n)[0];p=(document.all)?'scroll':'offset';
    eval("ifObj.style.width=window.frames[n].document.getElementsByTagName('body')[0]."+p+"Width+"+d);
    eval("ifObj.style.height=window.frames[n].document.getElementsByTagName('body')[0]."+p+"Height+"+d);
}
custom_addLoadEvent(resize_me);
//-->
</script>
See how I removed the (n) parameter and added 'n = ifr' to the function.

Regards,
Garvin

Posted: Fri Jun 16, 2006 4:16 pm
by thunder.x
sorry, i don´t get it :(

I made a new static page and added this:

Code: Select all

<script type="text/javascript">
<!--
function custom_addLoadEvent(func) {
          var oldonload = window.onload;
          if (typeof window.onload != 'function') {
            window.onload = func;
          } else {
            window.onload = function() {
              oldonload();
              func();
            }
          }
        }
function resize_me()
{
    n = 'ifr';
d=5;ifObj=document.getElementsByName(n)[0];p=(document.all)?'scroll':'offset';
    eval("ifObj.style.width=window.frames[n].document.getElementsByTagName('body')[0]."+p+"Width+"+d);
    eval("ifObj.style.height=window.frames[n].document.getElementsByTagName('body')[0]."+p+"Height+"+d);
}
custom_addLoadEvent(resize_me);
//-->
</script> 
<iframe id="ifr" name="ifr" width="900" height="500" src="../../cpg148/index.php" scroll="no">Sorry - Dein Browser unterstützt keine iframes</iframe>
with or without width and height initially set doesn´t seem to matter...



I just pasted this code into a standalone html-file and if I open it the iframe gets bigger if there is too much content... but why won´t it function with the static page plugin? :(

Posted: Fri Jun 16, 2006 4:46 pm
by garvinhicking
Hi!

What's the URL (your staticpage url) where you tested it on?

Regards,
Garvin

Posted: Fri Jun 16, 2006 5:17 pm
by thunder.x
the URL is "serendipity/index.php?/pages/testgalerie.html"

afaik it isn´t possible to use a pregenerated html-file to serve as static url? :(

Posted: Fri Jun 16, 2006 6:54 pm
by judebert
I think he'll need a server name, too; he probably wants to go have a look at the problem.

Meanwhile, yes, you can add standalone HTML to your s9y blog. Just put them in a subdirectory, and include an .htaccess in that directory with "RewriteEngine Off" in it.

(The problem is that Serendipity creates its own .htaccess that redirects everything to Serendipity. So you need some way to overrule it; that's what the above does.)

Posted: Sat Jun 17, 2006 3:09 am
by thunder.x
ah sorry about that! :)

http://www.meisterseite.net/testgalerie2.html is the standalone file I used to test the whole thing
then I have http://www.meisterseite.net/serendipity ... lerie.html as static-page

maybe i´ll try that thing with .htaccess, will search the forum here for this task later this day ;)

Posted: Sat Jun 17, 2006 5:01 pm
by garvinhicking
Hi!

SImply have a look at the output of your URL you send us.

There are "<br>"s all over your staticpage. The nl2br plugin does that to you; you'll need to disable that either completely or just for your single staticpage ("Apply markup transformations: no").

Regards,
Garvin

Posted: Sat Jun 17, 2006 5:20 pm
by thunder.x
hi!
I tried both: changing every radio button to "no" in the nl2br plugin and "textformatierungen durchführen" (apply markup transformations) to no as well as "als artikel formatieren" (format as article) ... still no change for me to see :(

Posted: Sat Jun 17, 2006 5:22 pm
by garvinhicking
Hi!

Can you make a complete screenshot of the page where you edit that staticpage and how you set the options?

Regards,
Garvin

Posted: Sat Jun 17, 2006 6:15 pm
by thunder.x
sure thing!

i uploaded it to www.meisterseite.net/screen.jpg

i hope this is sufficient, if not then please say so :)

btw: i changed the nl2br-plugin radiobuttons back to "yes"

Posted: Mon Jun 19, 2006 11:12 am
by garvinhicking
Hi!

Looking at your sourcecode, the '<br>'s are gone!

So the javascript seems to be executed, but it also seems that it does not work.

Try to modify your function like this (leave the rest as-is)

Code: Select all

function resize_me()
{
    n = 'ifr';
    alert('Resize function called.');
d=5;ifObj=document.getElementsByName(n)[0];p=(document.all)?'scroll':'offset';
    eval("ifObj.style.width=window.frames[n].document.getElementsByTagName('body')[0]."+p+"Width+"+d);
    eval("ifObj.style.height=window.frames[n].document.getElementsByTagName('body')[0]."+p+"Height+"+d);
    alert('Resize finished. If the page does not look okay, the javascript does not work - blame the author of that script. *g*');
}
HTH;
Garvin

Posted: Mon Jun 19, 2006 3:37 pm
by thunder.x
oh, it doesn´t work, i will try to get another script and work around with it ;)
thanks for your help garvin! much appreciated! :)
btw: what does "HTH;" mean?