• Forum
  • Doc
  • Screenshots
  • Download
  • Donate
  • Contributors
  • Contact
  • Follow @phpfreechat
  • DEMO
  • Board index ‹ Version 1.x branch ‹ How-to (v1.x)
  • Change font size
  • FAQ
  • Register
  • Login

Create a Channel list

A collection of how-to's, submitted by users for other users!

Moderator: re*s.t.a.r.s.*2

Post a reply
8 posts • Page 1 of 1

Postby IronLX » Sun Aug 21, 2011 12:47 pm

Step 1:
Insert this code into the <head> tags of the page with your chatroom (Default index.php)
Code: Select all
   <script type="text/javascript"> //additional Javascript to set commandbuttons
        function setBox(txt) {
          var thebox=document.getElementById("pfc_words")
            if (thebox) {
              thebox.value = txt
              pfc.doSendMessage()
            }
        }
  </script>

That creates a function that will send commands sent from outside the chat box.

Step 2:
Create your list using the HTML list tags.
Code: Select all
<u>Channels</u>
            <ul>
              <li>
               Channel 1
              </li>
              <li>
               Channel 2
              </li>
            </ul>

This list goes in somewhere in the <body> section of your HTML, position it accordingly to where you want the list to appear (You'll need to know some HTML/CSS to be able to do this cleanly).

Step 3:
Add the function calls with the arguments into the list items.
Code: Select all
<u>Channels</u>
            <ul>
              <li onClick="setBox('/join Channel 1')">
               Channel 1
              </li>
              <li onClick="setBox('/join Channel 2')">
               Channel 2
              </li>
            </ul>

In this case, because we used an HTML list it's the <li> tags that define the link, you can change the lists to a divider, a table, anything. When you click in it, the function will be called with the argument "/join", with some sense, you can change this to many things.

Notes:
If you want it to be a standard hyperlink, use the anchor <a> tag as normal, the href="" should point to the function call like so:
Code: Select all
<a href="setBox('/join Channel 2')">Join Channel 2</a>

If you want to grab a list of all channels with user count > 0 you'll need to know a bit more code, I haven't figured this one out yet as I don't yet need to, I'll update if I create the code or someone here posts it before me :)

Additional:
If you want to add commands to execute before they join the room (At one point I used the /leave command to leave the current room then join the new one), simply find this section in the function:
Code: Select all
thebox.value = txt
pfc.doSendMessage()

And then add this before it:
Code: Select all
thebox.value = "/leave"
pfc.doSendMessage()

That will make the user leave their current channel then join the channel they clicked on.

There are some timing bugs with doing another command AFTER joining the new channel, it sort of works but editing the join.class.php command is more likely to work.
Last edited by IronLX on Sun Aug 21, 2011 12:55 pm, edited 1 time in total.
IronLX
New member
 
Posts: 4
Joined: Sat Aug 20, 2011 12:59 pm
Top

Postby AllMad.org » Wed Sep 07, 2011 12:52 am

How would you make this so that you could place these links on other pages (not on the chat page)?
AllMad.org - the social ranting community.
AllMad.org
Member
 
Posts: 21
Joined: Mon Aug 22, 2011 2:31 am
Location: NS, Canada
  • Website
Top

Postby marc010 » Wed Sep 14, 2011 9:43 am

I would like a list of channels in use shown at the login screen (using the login tweak)... since rooms are created and dissapear so it must by dynamicly created. I'm using the MySQL container.
marc010
New member
 
Posts: 1
Joined: Tue Sep 13, 2011 10:56 am
Location: Rotterdam
  • Website
Top

Postby Gozmar » Sun Feb 26, 2012 10:13 am

is it also possible to pretect a channel with a password?
Gozmar
New member
 
Posts: 1
Joined: Sun Feb 26, 2012 10:10 am
Top

Postby DaveHass » Thu May 10, 2012 5:34 pm

hmm ... interesting and helpful. thanks!
DaveHass
New member
 
Posts: 2
Joined: Thu May 10, 2012 5:27 pm
Top

Re: Create a Channel list

Postby micaeli » Sat Nov 10, 2012 3:34 am

Very useful, many thanks, I try the code :idea:
micaeli
New member
 
Posts: 2
Joined: Sat Nov 10, 2012 3:04 am
  • Website
Top

Re: Create a Channel list

Postby itchibahn » Tue Nov 13, 2012 6:52 pm

Code: Select all
   
<script type="text/javascript">
    function setBox(txt) {
      var thebox=document.getElementById("pfc_words")
      if (thebox) {
        thebox.value = txt
        pfc.doSendMessage()
      }
    }
   
    function createRoom() {
       var x;
   var name=window.prompt("Enter new room name to create:");
   if (name!=null) {
        x=name;
        setBox('/join ' + x);
     }
    }
</script>

<button onclick="createRoom()">Create New Room</button>


This will let the end user to create their own channel.
.
.
.
-------------------------------------------------------------------------------
Currently working on NorJah
My failed websites: PC Share ISOT MultiByte
itchibahn
Member
 
Posts: 12
Joined: Sun Mar 16, 2008 6:33 pm
  • Website
Top

Re: Create a Channel list

Postby sylvinaross » Thu Aug 01, 2013 8:10 pm

I have been searching for this and finally got it here, I have tried it and i got great results. I am really thankful. :D
sylvinaross
New member
 
Posts: 1
Joined: Thu Aug 01, 2013 7:26 pm
Top


Post a reply
8 posts • Page 1 of 1

Return to How-to (v1.x)

Who is online

Users browsing this forum: No registered users and 0 guests

  • Board index
  • The team • Delete all board cookies • All times are UTC + 1 hour
Powered by phpBB® Forum Software © phpBB Group
Sign in
Wrong credentials
Sign up I forgot my password
.
jeu-gratuit.net | more partners
Fork me on GitHub