Page 1 of 3 123 LastLast
Results 1 to 10 of 22

Thread: how to create a pop-up in php forum

  1. #1
    Join Date
    Feb 2014
    Location
    Brampton, ON, Canada.
    Posts
    14
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default how to create a pop-up in php forum

    Hi, I would like to know how to create a pop-up message in phpbb forum index page only.
    What I am trying to achieve is that when a user lands on index.php page of my forum a pop-up should come and inside will be a message and a link to a page within my website.
    I am not sure how to make that work.
    I just want to have some kind of window popping up either be it using jQuery, JS etc. as long as it pops up to grab user's attention. Just like a private PM message would in php forums.
    Any help would be appreciated.

  2. #2
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    There are 2 files in the template folder where you could put a popup script for your forum index page;

    "phpBB3/styles/subsilver2/template/forumlist_body.html" - This is specific to the forum index so you should just be able to put a script here and only have it popup on the main index page - change "subsilver2" for your theme folder.

    And "phpBB3/styles/subsilver2/template/overall_header.html" - This is the header file for the whole forum, and every page, so you'd need to isolate only the index page when you're on it, by doing something like this;
    Code:
     <!-- PHP -->
    $page = basename(substr($_SERVER['PHP_SELF'],0,strrpos($_SERVER['PHP_SELF'],'.'))); // get web page and strip extension
    if ($page == 'index') { 
    <!-- ENDPHP -->
    
    ... Your HTML/JS here ...
    
    <!-- PHP --> 
    }
    <!-- ENDPHP -->
    The funny HTML comments that hold PHP and ENDPHP are phpBB's version of opening and closing PHP tags. To use them/custom PHP in the template files, you'll need to enable PHP in the ACP: https://www.phpbb.com/community/view...549d#p12913460

    To see the sample code above working, just paste it at the very bottom of the overall_header.html file (after you've enabled PHP via the ACP) and you'll only see " ... Your HTML/JS here ... " when you're on the main index page.

    So now you know where to put the code, you need to choose a popup script that you'd like to use. Have a look in the DD library as there may be something there, and have a play to see what you come up with.
    Last edited by Beverleyh; 02-18-2014 at 08:14 AM.
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  3. The Following User Says Thank You to Beverleyh For This Useful Post:

    itprosam (02-18-2014)

  4. #3
    Join Date
    Feb 2014
    Location
    Brampton, ON, Canada.
    Posts
    14
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    thanks Beverly
    I will try it and see if this works, will post updates...

    thanks it worked greatly
    much appreciated
    Last edited by itprosam; 02-18-2014 at 10:13 AM.

  5. #4
    Join Date
    Feb 2014
    Location
    Brampton, ON, Canada.
    Posts
    14
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    I quick follow-up
    what if I want to have that pop-up happen per session? (i.e. no popup until user closes and re-opens the browser and revisit website)

  6. #5
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    There are scripts that use a cookie in the DD library. Have you tried one of those?: http://www.dynamicdrive.com/dynamicindex17/

    Maybe the Sticky Note Script?: http://www.dynamicdrive.com/dynamici...stickynote.htm

    Or Stay on Top Content Script?: http://www.dynamicdrive.com/dynamici.../stayontop.htm
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  7. #6
    Join Date
    Feb 2014
    Location
    Brampton, ON, Canada.
    Posts
    14
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    I will try and post my results thanks

  8. #7
    Join Date
    Feb 2014
    Location
    Brampton, ON, Canada.
    Posts
    14
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    I checked it out but all those scripts advised to put something in HEAD and then BODY but as you know I am using php.. would I have to type a whole html page within the parameters you advised in previous script. 2nd I do not see any browser session coding in there or am I missing it??

  9. #8
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    PHP is the server side language that processes stuff on the server and queries the phpbb3 database etc, BUT, the output is in HTML - that's what is served to website visitors via a browsers and what you can see if you view the source.

    Look again in the aforementioned overall_header.html template file and you'll see familiar HTML elements such as the <head>, </head> and <body> tags - this is where you'd put your popup script according to the DD instructions. Assuming that you know your markup and do not rely on a WYSIWYG editor such as Dreamweaver, you can edit this template file like any other HTML document (and, just so you're aware, the closing </body> and </html> tags are located in the similarly named overall_footer.html file)
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  10. #9
    Join Date
    Feb 2014
    Location
    Brampton, ON, Canada.
    Posts
    14
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Thanks Beverly and I do not use any kind of WYSIWYG editor, I use Notepad or Notepad++
    I used your script mentioned above to modify "forumlist_body.html" and created an html page within the following code


    Code:
    <!-- PHP -->
    $page = basename(substr($_SERVER['PHP_SELF'],0,strrpos($_SERVER['PHP_SELF'],'.'))); // get web page and strip extension
    if ($page == 'index') { 
    <!-- ENDPHP -->
    
    ... Your HTML/JS here ...
    
    <!-- PHP --> 
    }
    <!-- ENDPHP -->

    The Following script is the one I used to make a pop-up per browser session:

    Step 1: Insert the following into the <head> section of your page

    Code:
    <script>
    
    /*
    Fair well window launcher script
    By JavaScript Kit ()
    Over 200+ free scripts here!
    */
    
    
    function openpopup(){
    //configure "seeyou.htm and the window dimensions as desired
    window.open("seeyou.htm","","width=300,height=338")
    }
    
    
    function get_cookie(Name) {
      var search = Name + "="
      var returnvalue = "";
      if (document.cookie.length > 0) {
        offset = document.cookie.indexOf(search)
        if (offset != -1) { // if cookie exists
          offset += search.length
          // set index of beginning of value
          end = document.cookie.indexOf(";", offset);
          // set index of end of cookie value
          if (end == -1)
             end = document.cookie.length;
          returnvalue=unescape(document.cookie.substring(offset, end))
          }
       }
      return returnvalue;
    }
    
    
    function loadpopup(){
    if (get_cookie('popped')==''){
    openpopup()
    document.cookie="popped=yes"
    }
    }
    
    
    </script>

    Step 2: Insert the following into the <body> tag itself, like this:


    Code:
    <body onload="loadpopup()">
    But Now the problem is Pop-up Blockers are blocking all the pop-ups hence I am looking for jQuery pop-up so it may not be blocked...
    Please advise...

  11. #10
    Join Date
    Feb 2014
    Location
    Brampton, ON, Canada.
    Posts
    14
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    after many tries I was able to run the stickynote script
    but its only coming up on Internet Explorer, It can't seem to load on Firefox and Chrome. Please check my coding and advise.


    Code:
    <html>
    <head>
    <style type="text/css">
    
    .stickynote{
    position:absolute;
    visibility:hidden;
    width: 300px;
    height: 100px;
    border: 2px solid black;
    background-color: grey;
    padding: 4px;
    box-shadow: 3px 3px 8px #818181;
    -webkit-box-shadow: 3px 3px 8px #818181;
    -moz-box-shadow: 3px 3px 8px #818181;
    }
    
    </style>
    
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
    
    <script src="stickynote.js">
    
    /***********************************************
    * Sticky Note Script (c) Dynamic Drive (www.dynamicdrive.com)
    * This notice MUST stay intact for legal use
    * Visit http://www.dynamicdrive.com/ for this script and 100s more.
    ***********************************************/
    
    </script>
    
    <script>
    
    var mysticky=new stickynote({
    	content:{divid:'stickynote1', source:'inline'},
    	showfrequency:'always',
    	hidebox:8
    })
    
    </script>
    
    </head>
    
    <div id="stickynote1" class="stickynote" align="center">
    <b><big><br><br>Please Support us by your donations.</big></b>
    
    <div align="center">
    <a href="#" onClick="mysticky.showhidenote('hide');return false">Hide Box</a>
    </div>
    
    </div>
    </body>
    </html>

Similar Threads

  1. Create html page that lets user create their own document
    By kc104 in forum Looking for such a script or service
    Replies: 0
    Last Post: 05-28-2009, 09:05 AM
  2. I Want To Create A Web Forum In Php
    By webboy in forum PHP
    Replies: 1
    Last Post: 06-07-2007, 03:14 PM
  3. Replies: 5
    Last Post: 01-21-2007, 09:09 PM
  4. I need a script that create a chat forum
    By Khabza in forum Dynamic Drive scripts help
    Replies: 1
    Last Post: 09-29-2005, 03:14 PM
  5. How would you create a forum???
    By sportious in forum The lounge
    Replies: 12
    Last Post: 08-06-2005, 08:10 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •