modifying static pages-output and/or wrapURL-output

Creating and modifying plugins.
thunder.x
Regular
Posts: 8
Joined: Fri Jun 16, 2006 1:39 am

modifying static pages-output and/or wrapURL-output

Post 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
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

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

Post 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
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
thunder.x
Regular
Posts: 8
Joined: Fri Jun 16, 2006 1:39 am

Post 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 ?
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post 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
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
thunder.x
Regular
Posts: 8
Joined: Fri Jun 16, 2006 1:39 am

Post 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? :(
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

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

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
thunder.x
Regular
Posts: 8
Joined: Fri Jun 16, 2006 1:39 am

Post 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? :(
judebert
Regular
Posts: 2478
Joined: Sat Oct 15, 2005 6:57 am
Location: Orlando, FL
Contact:

Post 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.)
Judebert
---
Website | Wishlist | PayPal
thunder.x
Regular
Posts: 8
Joined: Fri Jun 16, 2006 1:39 am

Post 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 ;)
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post 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
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
thunder.x
Regular
Posts: 8
Joined: Fri Jun 16, 2006 1:39 am

Post 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 :(
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post 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
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
thunder.x
Regular
Posts: 8
Joined: Fri Jun 16, 2006 1:39 am

Post 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"
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post 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
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
thunder.x
Regular
Posts: 8
Joined: Fri Jun 16, 2006 1:39 am

Post 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?
Post Reply