Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Not a member yet? Click here to register.
Forgot Password?

Custom page with php - wrong links

Asked Modified Viewed 1,761 times
Q
quiki
Q
quiki 10
  • Member, joined since
  • Contributed 171 posts on the community forums.
  • Started 41 threads in the forums
  • Started this discussions
asked
Member

Hi, I'm making a twitch streaming that shows online and offline users. When I put the code in a custom page the links get wrong. Any idea how to fix this?
Here is my site which is not working if you press a stream (you can see the link by holding the mouse over: http://pcgamer.no/viewpage.php?page_i...page_id=42

When the code is not in a "Custom page" it is working as you can see here: http://pcgamer.no/twitchchannelswitcher/

Attached the code

Merged on Jan 06 2016 at 11:07:59:
When clicking on the stream, it should show in the window on top.
Edited by quiki on 06-01-2016 11:07,
quiki attached the following file:
code_1.zip [No information available / 135 Downloads]
0 replies

6 posts

F
Falk
F
Falk 146
Need help?, Having trouble?
• View our Documentation for Guides, Standards and Functions
• Name and Organize your Topics and Content correctly in the corresponding Forums for best support results
• Attaching Log Files and Screenshots when reporting issues will help
• Provide with an URL to live example if one exists
• Please read the How to Report an Error post
• Please read and comply with the Code of Conduct

(¯·._.·(¯°·._.·°º*[ Project Manager ]*º°·._.·°¯)·._.·¯)
  • Super Admin, joined since
  • Contributed 6,201 posts on the community forums.
  • Started 639 threads in the forums
  • Answered 12 questions
answered
Super Admin

Seems to be in the api, all links point to scripts dir index.php, find how to change that.
0 replies
Q
quiki
Q
quiki 10
  • Member, joined since
  • Contributed 171 posts on the community forums.
  • Started 41 threads in the forums
  • Started this discussions
answered
Member

Ok, I'll try to find out where I can change this in the index.php, thx

Merged on Jan 06 2016 at 13:02:33:
Think I found it, but still not working:
Tried to add the following:

Quote

<a href="http://pcgamer.no/viewpage.php?page_id=42?channel='.$value.'"> <h3>'.$value.'</h3> </a>


Previously it was:

Quote

<a href="?channel='.$value.'"> <h3>'.$value.'</h3> </a>
Edited by quiki on 06-01-2016 13:02,
0 replies
F
Falk
F
Falk 146
Need help?, Having trouble?
• View our Documentation for Guides, Standards and Functions
• Name and Organize your Topics and Content correctly in the corresponding Forums for best support results
• Attaching Log Files and Screenshots when reporting issues will help
• Provide with an URL to live example if one exists
• Please read the How to Report an Error post
• Please read and comply with the Code of Conduct

(¯·._.·(¯°·._.·°º*[ Project Manager ]*º°·._.·°¯)·._.·¯)
  • Super Admin, joined since
  • Contributed 6,201 posts on the community forums.
  • Started 639 threads in the forums
  • Answered 12 questions
answered
Super Admin

Do it like,
<a href="http://pcgamer.no/viewpage.php?page_id=42&amp;channel='.$value.'"> <h3>'.$value.'</h3> </a>
0 replies
Q
quiki
Q
quiki 10
  • Member, joined since
  • Contributed 171 posts on the community forums.
  • Started 41 threads in the forums
  • Started this discussions
answered
Member

Damn, did'nt to the trick, but thanks for your answer.

Anyone else have an idea how to fix this? Sorry for being newb at this.

<html>
<head>
<title>STREAMS</title>
<link rel="stylesheet" type="text/css" href="/twitchchannelswitcher/images/stream.css" />
</head>
<body>
<div class="wrapper">
 <div class="viewer">
 <?php
 $channel = $_GET["channel"];
 if($channel == null){
    //default channel
    $channel = "admiralbulldog";
 }
 //places the flash video viewer $channel can be given as a url argument i.e. http://www.maegis.net/index.php/stream-list/?channel=maegis
 echo '<object type="application/x-shockwave-flash" height="400" width="494" id="live_embed_player_flash" data="http://nl.twitch.tv/widgets/live_embed_player.swf?channel='.$channel.'" bgcolor="#000000"><param    name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always" /><param name="allowNetworking" value="all" /><param name="movie" value="http://nl.twitch.tv/widgets/live_embed_player.swf" /><param name="flashvars" value="hostname=www.twitch.tv&channel='.$channel.'&auto_play=true&start_volume=25" /></object>
<iframe frameborder="0" scrolling="no" id="chat_embed" src="http://twitch.tv/chat/embed?channel='.$channel.'&amp;popout_chat=true" height="400" width="300"></iframe>'; ?>
 </div>
    </br>
    <hr>
 
<?php

/**
* @version   1.0 for twitch api 2.0
* @copyright (C) 2012/2013 Cees Middel (Avon) www.maegis.net
* @Inspired by Syi http://mushroom-mayhem.com
* @license   GNU/GPL v3 http://www.gnu.org/licenses/gpl.html
*/

/**
* array with all stream names i.e. www.twitch.tv/"maegis".
* To add more users just add their channel names with comma seperation
* This is all there is, no futher editing required
*/
$members = array("admiralbulldog","wintergaming","olofmeister","draksyl","dragon","flusha","demuslim","dendi","acermma","aliastar","trumpsc","officialgetright","hiko","merlinidota","liquidmana","liquidsnute","beyondthesummit");

// This variable becomes one long url with the channel names stringed up behind it
// This url then fetches a json file from twitch with all the selected channels information
$userGrab = "https://api.twitch.tv/kraken/streams?channel=";

//I use this array to compare with the members array. All users in this arrat are substracted from the members array and hence are //"offline"
$checkedOnline = array ();

foreach($members as $i =>$value){
   $userGrab .= ",";
   $userGrab .= $value;
}

//grabs the channel data from twitch.tv streams
$twitchChannels_array = json_decode(get_url_contents($userGrab));

foreach($twitchChannels_array->streams as $i => $value){
         $title = $twitchChannels_array->streams[$i]->channel->name;
         $viewer = $twitchChannels_array->streams[$i]->viewers;
         $topic = $twitchChannels_array->streams[$i]->channel->status;
         $thumb = $twitchChannels_array->streams[$i]->preview->medium;
         onlinecheck($title, $viewer, $thumb, $topic);   
         $checkedOnline[] = signin($title);         
}

//checks if player streams are online
function onlinecheck($online, $viewers, $thumb, $topic)
    { 
   //If the variable online is not equal to null, there is a good change this person is currently streaming
         if ($online != null)
            {
                   echo '<div class="stream_main">
                   <div class="stream_ thumb">
                   <a href="index.php?channel='.$online.'"> <img src="'.$thumb.'" class="thumb_bg" width="188" height="113"/></a>
                   </div>
                   <div class="stream_title">
                   <a href="index.php?channel='.$online.'"> <h3>'.$online.'</h3> </a>
                   </div>
                  <div class="stream_info">
                   &nbsp<img src="/twitchchannelswitcher/images/online.png"> Online &nbsp<img src="/twitchchannelswitcher/images/viewers.png">&nbsp '.$viewers.'</br>
                  </div>
                   </div>';
                            
         }
   }
   
//This funcion add's online channel names to the checked online array
function signin($person){
   if($person != null){
      return $person;
   }
   else{
      return null;
   }
}

function get_url_contents($url){
   $crl = curl_init();
   $timeout = 5;
   curl_setopt ($crl, CURLOPT_URL,$url);
    curl_setopt ($crl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt ($crl, CURLOPT_CONNECTTIMEOUT, $timeout);
    $ret = curl_exec($crl);
    curl_close($crl);
   return $ret;
}   

//This part list all the people currently offline. Here the array with online users is compared with the total users.
//online users are then removed from the total users array.
   foreach ($members as $i => $value1) {
      foreach($checkedOnline as $ii => $value2){
         if($value1 == $value2){
            unset($members[$i]);
         }
      }
         
   }
   
   foreach ($members as $i => $value) {
       echo '<div class="stream_main">
       <div class="stream_ thumb">
       <img class="thumb_bg" src="/twitchchannelswitcher/images/offline_thumb.png" width="188" height="113"/>
       </div>
       <div class="stream_title">
       <a href="?channel='.$value.'"> <h3>'.$value.'</h3> </a>
       </div>
       <div class="stream_info">
       &nbsp<img src="/twitchchannelswitcher/images/offline.png"> Offline </br>
       </div>
       </div>';
   }
?>
</div>
<div class = "footer">
<p> TwitchList (C)2013 created by Cees Middel for www.maegis.net </p>
</div>
</body>
</html>
0 replies
F
Falk
F
Falk 146
Need help?, Having trouble?
• View our Documentation for Guides, Standards and Functions
• Name and Organize your Topics and Content correctly in the corresponding Forums for best support results
• Attaching Log Files and Screenshots when reporting issues will help
• Provide with an URL to live example if one exists
• Please read the How to Report an Error post
• Please read and comply with the Code of Conduct

(¯·._.·(¯°·._.·°º*[ Project Manager ]*º°·._.·°¯)·._.·¯)
  • Super Admin, joined since
  • Contributed 6,201 posts on the community forums.
  • Started 639 threads in the forums
  • Answered 12 questions
answered
Super Admin

Just change all them links with that path I gave you.
0 replies
Q
quiki
Q
quiki 10
  • Member, joined since
  • Contributed 171 posts on the community forums.
  • Started 41 threads in the forums
  • Started this discussions
answered
Member

Perfect, thanks for the help Domi! Very helpfull as always :D
0 replies

Labels

None yet

Statistics

  • Views 0 views
  • Posts 6 posts
  • Votes 0 votes
  • Topic users 2 members

2 participants

F
F
Falk 146
Need help?, Having trouble?
• View our Documentation for Guides, Standards and Functions
• Name and Organize your Topics and Content correctly in the corresponding Forums for best support results
• Attaching Log Files and Screenshots when reporting issues will help
• Provide with an URL to live example if one exists
• Please read the How to Report an Error post
• Please read and comply with the Code of Conduct

(¯·._.·(¯°·._.·°º*[ Project Manager ]*º°·._.·°¯)·._.·¯)
  • Super Admin, joined since
  • Contributed 6,201 posts on the community forums.
  • Started 639 threads in the forums
  • Answered 12 questions
Q
Q
quiki 10
  • Member, joined since
  • Contributed 171 posts on the community forums.
  • Started 41 threads in the forums
  • Started this discussions

Notifications

Track thread

You are not receiving notifications from this thread.

Related Questions

Not yet