WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: pb-embedFlash] Automatically open on page load (33 posts)

  1. martinbennett
    Member
    Posted 6 years ago #

    I am successfully using the [Plugin: pb-embedFlash] from within a post to load a html page containing a slideshow, using the shadowbox feature. I would like to automatically load an html page also containing a slideshow from a wordpress page link.

    Is this possible and if so how? Can i activate it via javascript by editing the html of the page using the wordpress "write page" function.

    Many thanks

    Martin

  2. pasber
    Member
    Posted 6 years ago #

    Do you want to open the shadowbox automatically on page finnished loading or open shadowbox when clicking on the page link (instead of loading a page)?

    To 1.: This can be made by adding JavaScript to your page. When I'm back home (tomorrow), I could give an example.

    To 2.: This is a bit more tricky because you have to edit the template files. You need to create the box' content manually and add the "page" link to the page list/bar. pb-embedFlash cannot help here.

  3. martinbennett
    Member
    Posted 6 years ago #

    The best solution or more elegant would be the second one. But if its not possible it would also be ok to load the shadowbox overlay after the page link had finished loading.

    Many thanks

    for your help

  4. pasber
    Member
    Posted 6 years ago #

    I suggest to write a dummy post with the [flash ...] you wish to use. Open the blog post and copy the link generated for Shadowbox:
    <a class="shadowbox" ... rel="shadowbox..." href="http://...">

    Edit your template file and paste the code where you wish.

    And don't forget to check the pb-embedFlash option page if "Load Shadowbox by default even if there is no flash content displayed [...]" is checked.

    For further help I need a link to your blog. :)

  5. martinbennett
    Member
    Posted 6 years ago #

    i tried your solution but i get errors. or nothing happens. (i must admit i am no programmer!)

    i created a .php page for my wordpress page link called overview.php and set up the page Over to use this template. And inserted the shadowbox code into it. But no popup layer...

    My blog url is http://www.blog.martinbennett.com/
    and the page link i want to call the html flash file from is http://www.blog.martinbennett.com/overview/

    I hope you can help

    Many thanks

    Martin

  6. pasber
    Member
    Posted 6 years ago #

    Using the second solution you don't have to add a page link in the admin control panel but directly in your template file. I'll take a look on it the next days. A bit busy at the moment.

  7. brendafos
    Member
    Posted 6 years ago #

    I've installed and activated. In the wp-admin under Options I have the pb-embedFlash page. But for Write or Manage I don't have any tools to do the tag generation. Is it because I don't have the tinyMCE or other plugins?

  8. pasber
    Member
    Posted 6 years ago #

    Yes, you're right. That's why it's called "TinyMCE popup" :).

  9. martinbennett
    Member
    Posted 6 years ago #

    Hello
    Dont want to be pushy but was wondering if you had any time to look into the page link problem?
    Many thanks

    Martin

  10. pasber
    Member
    Posted 6 years ago #

    <li class="page_item">
    	<a href="http://blog.martinbennett.com/wp-content/uploads/overview/" title="Overview" rel="shadowbox;height=900;width=1000">
    		Overview
    	</a>
    </li>

    This is the code to use. It should be place after wp_list_pages(...) inside an ul tree. I found it three times on your page. (page list above your posts (maybe header.php), navigation (sidebar.php) and in your footer region (bottom.php/footer.php). Maybe you want to change width&height.

    If you do so, you should delete the page link "Overview" in your admin panel.

  11. martinbennett
    Member
    Posted 6 years ago #

    Many many thanks it works a treat.
    Ill buy you a beer

    martin

  12. pasber
    Member
    Posted 6 years ago #

    That pleases me! Thanks for your donation!

  13. martinbennett
    Member
    Posted 5 years ago #

    In your very first response you suggested that it was easy to implement a javascript to automatically load shadowbow / pb-embedflash. I would like to set up a splash page that automatically loads a jpeg. Could you help me with the code?

    Many thanks

    Martin

  14. pasber
    Member
    Posted 5 years ago #

    The Shadowbox FAQ knows it :). But as of I'm not using the latest version, most of the content cannot be applied to my plugin.

    But the following code from the FAQ should work:

    <script type="text/javascript">
    var openShadowbox = function(content, player, title){
        Shadowbox.open({
            content:    content,
            player:     player,
            title:      title
        });
    };
    </script>
  15. martinbennett
    Member
    Posted 5 years ago #

    i have tried to get the autoload function to work but with no sucess

    <script type="text/javascript">
    var openShadowbox = function(content, player, title){
    Shadowbox.open({

            content:    'http://www.martinbennett.com/uploads/portfolio/index.html',
    player:     'html',
            title:      'Martin Bennett - Photographer'
        });

    };

    </script>

    i placed this in the header.php of my template is that correct?

    Any help would be apreciated

    Many thanks

    Martin

  16. pasber
    Member
    Posted 5 years ago #

    Maybe I was a bit unclear. The following script should be copied "as is" to your header.php:

    <script type="text/javascript">
    var openShadowbox = function(content, player, title){
        Shadowbox.open({
            content:    content,
            player:     player,
            title:      title
        });
    };
    </script>

    Afterwards, you can use the function to load something:
    openShadowbox('http://www.martinbennett.com/uploads/portfolio/index.html', 'html', 'Martin Bennett - Photographer');

    But how should the parser know, when exactly to load the function. Well... that's really a bit tricky.

    function callOpenShadowbox() {
      openShadowbox('http://www.martinbennett.com/uploads/portfolio/index.html', 'html', 'Martin Bennett - Photographer');
    }
    
    if(window.onload) {
      var temp = window.onload;
      window.onload=function(e) {
        temp(e);
        callOpenShadowbox();
      };
    }
    else{
      window.onload=function(e) {
        callOpenShadowbox();
      };
    }

    The window.onload method can only be applied once, so we need to re-apply the old script (load the Shadowbox script) and add the new script (open the box directly onload).

    I couldn't test anything yet, but basically, the code should work.

    --- below this, there's a bit offtopic stuff ---

    Everything would be alot easier, but Microsoft does not implement the standard way "addEventListener" and has its own function "attachEvent". Loading only two scripts, it would a bunch too much code to do it the "nice" way:

    /* for Mozilla/Safari(?)/Opera9*/
    if (document.addEventListener) {
      document.addEventListener("DOMContentLoaded", init, false);
    }
    
    /* for Internet Explorer */
    /*@cc_on @*/
    /*@if (@_win32)
      document.write("<script id=__ie_onload defer src=javascript:void(0)><\/script>");
      var script = document.getElementById("__ie_onload");
      script.onreadystatechange = function() {
        if (this.readyState == "complete") {
          init(); // call the onload handler
        }
      };
    /*@end @*/
    /* fallback for other browsers */
    window.onload = init;

    (init = function to load)

    See? :(

  17. martinbennett
    Member
    Posted 5 years ago #

    i added the shadowbox javascript to the header.php as you suggested.

    do i add the function to load something:
    openShadowbox('http://www.martinbennett.com/uploads/portfolio/index.html', 'html', 'Martin Bennett - Photographer');

    also in the header.php or do i place it elsewhere?

    I tried it after the first code but nothing happened...

  18. pasber
    Member
    Posted 5 years ago #

    You need to call that option "onload", means after the page has finnished loading.

    So I suggest to try the second code snippet from my prior post:

    function callOpenShadowbox() {
      openShadowbox('http://www.martinbennett.com/uploads/portfolio/index.html', 'html', 'Martin Bennett - Photographer');
    }
    
    if(window.onload) {
      var temp = window.onload;
      window.onload=function(e) {
        temp(e);
        callOpenShadowbox();
      };
    }
    else{
      window.onload=function(e) {
        callOpenShadowbox();
      };
    }
  19. martinbennett
    Member
    Posted 5 years ago #

    ok but where do i place the second code?

  20. pasber
    Member
    Posted 5 years ago #

    I could now test the thing and there is basically one change: It's type: 'iframe' instead of player: 'html'.

    Anyways, I simplified the code a bit:

    <script type="text/javascript">
    	var openShadowbox = function(){Shadowbox.open({
    	        content:    'http://www.martinbennett.com/uploads/portfolio/index.html',
    	        type:     	'iframe',
    	        title:      'Martin Bennett - Photographer'
    	    })};
    	if(window.onload) {
    	  var temp = window.onload;
    	  window.onload=function(e) {
    	    temp(e);
    	    openShadowbox();
    	  };
    	}
    	else{
    	  window.onload=function(e) {
    	    openShadowbox();
    	  };
    	}
    </script>

    Just copy the bunch anywhere after calling wp_head();.

    Worked fine for me.

  21. martinbennett
    Member
    Posted 5 years ago #

    thank you that works a treat!

    Martin

  22. martinbennett
    Member
    Posted 5 years ago #

    just noticed a problem in safari and firefox the autoloader works but if i close the shadowbox layer and click on another page link it loads the layer again.

    I need it to only autoload on the first page: you can see it in action here

    http://test.martinbennett.com

    if you click on contact or Biography (which are pages) the shadowbox layer loads on top.

  23. pasber
    Member
    Posted 5 years ago #

    Of course you should paste the code only on pages where it should be. Currently, the script is loaded on each page/post.

    You could check via php if it's is_home() or something like that.

    Loading the Layer only once a session would also be possible, but is beyond my plugin and requires some programming skills.

  24. martinbennett
    Member
    Posted 5 years ago #

    is it possible to have the autoload on the first / home page of the domain but not on the other pages or posts?

  25. pasber
    Member
    Posted 5 years ago #

    <?php if (is_home()) { ?>
    <script type="text/javascript">
    var openShadowbox = function(){Shadowbox.open({
            content:'http://www.martinbennett.com/uploads/portfolio/index.html',
            type:	'iframe',
            title:	'Martin Bennett - Photographer'
        })};
    if(window.onload) {
      var temp = window.onload;
      window.onload=function(e) {
        temp(e);
        openShadowbox();
      };
    }
    else{
      window.onload=function(e) {
        openShadowbox();
      };
    }
    </script>
    <?php } ?>

    This should automatically load the shadowbox only on your index/home page, not on pages or posts. A simple PHP condition. :)

  26. gioffry
    Member
    Posted 5 years ago #

    Hi,
    good guide

    but when ii try to use it in my site, it not works.
    I have a flash site.

    HTML

    <script type="text/javascript">
    
    var openShadowbox = function(content, player, title){
        Shadowbox.open({
            content:    content,
            player:     player,
            title:      title
        });
    };
    
    </script>
    <script type="text/javascript">
    	var openShadowbox = function(){Shadowbox.open({
    	        content:    'http://www.kickersjunior.it/pe-09/girl.html',
    	        type:     	'iframe',
    	        title:      'Girl'
    	    })};
    	if(window.onload) {
    	  var temp = window.onload;
    	  window.onload=function(e) {
    	    temp(e);
    	    openShadowbox();
    	  };
    	}
    	else{
    	  window.onload=function(e) {
    	    openShadowbox();
    	  };
    	}
    </script>

    FLASH

    on (release) {
    	getURL("javascript:openShadowbox('http://www.kickersjunior.it/pe-09/girl.html', 'iframe', 'Girl'););");
    }

    thank you

  27. pasber
    Member
    Posted 5 years ago #

    Hmm you're messing lots of things up.

    First of all, you define a function twice (openShadowbox). In the snippet I wrote for for martinbennett, openShadowbox was just a placeholder to call Shadowbox.open [no need to write the whole part twice so I put it into a variable].

    Then, you keep the onload functions, but you don't need them - via flash, you can open the Shadowbox "whenever you want" easily.

    So I suggest you delete all the HTML/JavaScript you've posted above and call

    Shadowbox.open({content:'http://www.kickersjunior.it/pe-09/girl.htm',type:'iframe',title:'Girl'})

    directly in getURL().

  28. gioffry
    Member
    Posted 5 years ago #

    no, the error is here:

    'Girl'););");

    i wrote ); two times
    now works!

    but now i have another problem: can i set page size?
    In html is:

    rel="shadowbox;width=200;height=200"

    in flash?

    ...

    Thank You

  29. pasber
    Member
    Posted 5 years ago #

    Well, I guess your code will work as I posted, as of you're giving parameters to openShadowbox(), but tht function does not accept parameters and just does what it should: call Shadowbox.open() with the predefined values.

    To the rel attribute problem: I don't know flash that good, sorry.

  30. gioffry
    Member
    Posted 5 years ago #

    Here, an user says to another user:

    just added some extra parameters for customization, when using shadowbox for "media".

    function abrirSB(type, title, url, width, height)
    {
    Shadowbox.init({skipSetup: true});
    Shadowbox.open({type: type, title: title, content: url, width: width, height: height});
    };

    and into flash file:

    getURL("javascript:abrirSB('img', 'Title', 'image.jpg', '' ,'');", "_self");

    First value 'img' can be: "swf", "flv", "qt" (QuickTime), "wmp" (Windows Media Player), "iframe", or "html". For custom sized iframe, it will look something like this:

    getURL("javascript:abrirSB('iframe', 'Title', 'image.jpg', '450' ,'450');", "_self");

    that's all!

    so i wrote in html:

    <script type="text/javascript">
    
    var openShadowbox = function(content, player, title){
        Shadowbox.open({
            content:    content,
            player:     player,
            title:      title,
    		width: 		width,
    		height: 	height
        });
    };
    
    </script>

    and in flash file, i wrote:

    on (release) {
    	getURL("javascript:openShadowbox('http://www.kickersjunior.it/retailer/richiesta.php', 'iframe', 'Ricerca Punti Vendita', '200', '200');");
    }

    but doesn't work :(

Topic Closed

This topic has been closed to new replies.

About this Topic