LeagueCMS
competition management for DragonFly CMS

making it so blocks can display different events

The public support form for mComp, online gaming Competition Management Software
Reply to topicReply to topic Printer Friendly Page
Forum FAQSearchView unanswered posts
Go to page 1, 2  Next

making it so blocks can display different events

Post Posted: Mon Sep 22, 2008 4:58 pm

Is there an easy way I could make it so that i could have a block to show only certain events ie a perks on ladders and then another block that would show the perks off ladders etc?

By the way this is the best module ive come across for about 5 years, thanks for all the work you've done matey Very Happy

Mike

mikesu
Newbie
Newbie
 

making it so blocks can display different events

Post Posted: Mon Sep 22, 2008 6:05 pm

Most of the blocks are designed to show data from the currently being viewed Event. If you wanted to hard-code a specific event you could do so reasonably easily, you'd just need to know the Event ID number.

In, for example, the block Competition Table you'll see this code:-

Code:
$inc = '';
if (defined('MCOMP_CURRENT_GAME'))  { $inc .= ' AND a.game='.MCOMP_CURRENT_GAME;   }
if (defined('MCOMP_CURRENT_EVENT')) { $inc .= ' AND a.event='.MCOMP_CURRENT_EVENT; }

Replace that with :-

Code:
$inc = ' AND a.event=X';

where X is the ID number of the Event you want to show.

If you want 2 blocks the same but showing different Events, just copy the block and give it a new name, like block-Competition-Table2.php. Make sure however that it follows the same naming convention, block-Competition-whatever.php

mark
Site Admin
Site Admin
 

Re: making it so blocks can display different events

Post Posted: Mon Sep 22, 2008 9:51 pm

thats great Mark!

Thanks loads

Mike

Just tried it, comes back with error on line 142 Sad

mikesu
Newbie
Newbie
 

making it so blocks can display different events

Post Posted: Tue Sep 23, 2008 5:36 am

Line 142 of what? There aren't 142 lines in block-Competition-Table.php. What's the actual error you're getting?

mark
Site Admin
Site Admin
 

making it so blocks can display different events

Post Posted: Tue Sep 23, 2008 10:10 am

includes/classes/blocks.php

* CMS Warning line 142: block-Competition-Table9.php
There appears to be a problem with this block


used the Competition-Table2.php block and editied like you said

Mike

mikesu
Newbie
Newbie
 

making it so blocks can display different events

Post Posted: Tue Sep 23, 2008 10:42 am

Can you copy / paste the contents of your new block here so I can take a look.

mark
Site Admin
Site Admin
 

making it so blocks can display different events

Post Posted: Tue Sep 23, 2008 8:18 pm

<?php

/***********************************************************************
Competition Module
==================
Copyright (c) 2007 - www.cmsdreams.co.uk

Note:-

THIS SOFTWARE IS NOT FREE AND IS NOT RELEASED UNDER GPL.

COPYRIGHT IN THIS SOFTWARE REMAINS WITH THE AUTHOR AND IS NOT TRANSFERABLE.

YOU ARE PERMITTED TO INSTALL THIS SOFTWARE ON ONE WEBSITE ONLY.
SHOULD YOU REQUIRE ADDITIONAL COPIES PLEASE CONTACT THE AUTHOR TO DISCUSS
MULTIPLE LICENSE TERMS.

YOU ARE NOT PERMITTED TO RE-DISTRIBUTE OR RE-SELL THIS SOFTWARE IN ANY FORM,
NOR ARE YOU ALLOWED TO MODIFY THIS SOFTWARE AND RE-DISTRIBUTE OR RE-SELL
THE MODIFIED VERSION IN ANY FORM.

THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/

// slot - competitor - points - played

if (!defined('CPG_NUKE')) { exit; }

$name_parts = explode('-',basename(__FILE__));
$thismod = $name_parts[1];
if (!is_active($thismod)) {
$content = 'ERROR';
return trigger_error($thismod.' is not Active!', E_USER_WARNING);
}

global $prefix, $user_prefix, $db;
$thispfx = $prefix.'_'.((strcmp($thismod,'Competition')==0)?'comp':strtolower($thismod));

$res = $db->sql_query('SELECT * FROM '.$thispfx.'config');
if (!$res) { return trigger_error('Configuration File Missing for '.$thismod, E_USER_WARNING); }
while ($row = $db->sql_fetchrow($res)) {
$mcomp[$row['cfg_field']] = $row['cfg_value'];
}
$db->sql_freeresult($res);

$content = '';

$inc = ' AND a.event=10';
if (defined('MCOMP_CURRENT_GAME')) { $inc .= ' AND a.game='.MCOMP_CURRENT_GAME; }
if (defined('MCOMP_CURRENT_EVENT')) { $inc .= ' AND a.event='.MCOMP_CURRENT_EVENT; }



$sql = '
SELECT
a.game, a.event, a.division, a.slot, a.cid, a.wins, a.draws, a.losses, a.points,
g.gname, g.gshort, g.gicon, e.ename, d.dname, t.tid, t.pid, t.tname, t.ttag, t.tcountry, u.username
FROM '.$thispfx.'division_team AS a
INNER JOIN '.$thispfx.'game AS g ON (g.game=a.game)
INNER JOIN '.$thispfx.'event AS e ON (e.event=a.event)
INNER JOIN '.$thispfx.'division AS d ON (d.division=a.division)
INNER JOIN '.$thispfx.'team AS t ON (t.cid=a.cid)
LEFT JOIN '.$user_prefix.'_users AS u ON (u.user_id=t.pid)
WHERE a.division > 0
AND e.pid = 0
AND (e.etype = 1
OR e.etype = 5)
AND e.estartdate <= \''.date('Y-m-d H:i').'\'
AND e.eenddate >= \''.date('Y-m-d H:i').'\'
'.$inc.'
ORDER BY a.game, a.event, a.division, a.slot';
$res = $db->sql_query($sql);
if ($db->sql_numrows($res)) {
$thisgame = 0; $thisevnt = 0; $thisdivn = 0; $newgame = false;
$content = '<table width="100%" border="0" cellpadding="1" cellspacing="1">';
while ( list($game, $event, $division, $slot, $cid, $wins, $draws, $losses, $points, $gname, $gshort, $gicon, $ename, $dname, $tid, $pid, $tname, $ttag, $tcountry, $username) = $db->sql_fetchrow($res) ) {
if ($game != $thisgame || $event != $thisevnt) {
$gname = '<a href="'.getlink($thismod.'&game='.$game).'"><img src="modules/'.$thismod.'/images/icons/'.$gicon.'" alt="'.$gname.'" title="'.$gname.'" border="0" /> '.$gshort.'</a>';
$ename = '<a href="'.getlink($thismod.'&event='.$event).'">'.$ename.'</a>';
if ($newgame) {
$content .= '<tr><td colspan="4"><hr noshade size=1 /></td></tr>';
}
$content .= '<tr><td align="left" colspan="4">'.$gname.' '.$ename.'</td></tr>';
$thisgame = $game; $thisevnt = $event; $newgame = true;
}
if ($division != $thisdivn) {
$content .= '
<tr>
&lt;td align="left" colspan="2"&gt;<b>'.$dname.'</b>&lt;/td&gt;
&lt;td align="center"&gt;<b>Pts</b>&lt;/td&gt;
&lt;td align="center"&gt;<b>Pld</b>&lt;/td&gt;
&lt;/tr&gt;
';
$thisdivn = $division;
}
$tname = ($tid!=0 && $pid==0) ? (($ttag=='')?$tname:$ttag) : $username ;
$tlink = ($tid!=0 && $pid==0) ? getlink($thismod.'&file=teams&op=teamProfile&cid='.$cid) : getlink($thismod.'&file=players&op=playerProfile&cid='.$cid) ;
$tname = '&lt;a href="'.$tlink.'"&gt;'.$tname.'&lt;/a&gt;';
$tname = '&lt;img src="images/flags/'.$tcountry.$mcomp['flag_ext'].'" border="0"&gt;&nbsp;'.$tname;
$content .= '
&lt;tr&gt;
&lt;td align="left"&gt;'.$slot.'&lt;/td&gt;
&lt;td align="left"&gt;'.$tname.'&lt;/td&gt;
&lt;td align="center"&gt;'.$points.'&lt;/td&gt;
&lt;td align="center"&gt;'.($wins + $draws + $losses).'&lt;/td&gt;
&lt;/tr&gt;
';
}
$content .= '&lt;/table&gt;';
}
$db->sql_freeresult($res);

?>

mikesu
Newbie
Newbie
 

making it so blocks can display different events

Post Posted: Wed Sep 24, 2008 5:41 am

Remove these 2 lines:-

Code:
if (defined('MCOMP_CURRENT_GAME'))  { $inc .= ' AND a.game='.MCOMP_CURRENT_GAME;   }
if (defined('MCOMP_CURRENT_EVENT')) { $inc .= ' AND a.event='.MCOMP_CURRENT_EVENT; }

And make sure you edit the file with a UTF-8 compatible text editor, which Windows Notepad is NOT. Use Wordpad if you don't have anything else.

mark
Site Admin
Site Admin
 

making it so blocks can display different events

Post Posted: Wed Sep 24, 2008 11:09 am

yeah only had wordpad as i was on my laptop,

Will give it a go

Mike

mikesu
Newbie
Newbie
 

making it so blocks can display different events

Post Posted: Wed Sep 24, 2008 11:21 am

edited the block with UFT-8 editor

Still getting the same error with the adjustments Sad

&lt;?php

/***********************************************************************
Competition Module
==================
Copyright (c) 2007 - www.cmsdreams.co.uk

Note:-

THIS SOFTWARE IS NOT FREE AND IS NOT RELEASED UNDER GPL.

COPYRIGHT IN THIS SOFTWARE REMAINS WITH THE AUTHOR AND IS NOT TRANSFERABLE.

YOU ARE PERMITTED TO INSTALL THIS SOFTWARE ON ONE WEBSITE ONLY.
SHOULD YOU REQUIRE ADDITIONAL COPIES PLEASE CONTACT THE AUTHOR TO DISCUSS
MULTIPLE LICENSE TERMS.

YOU ARE NOT PERMITTED TO RE-DISTRIBUTE OR RE-SELL THIS SOFTWARE IN ANY FORM,
NOR ARE YOU ALLOWED TO MODIFY THIS SOFTWARE AND RE-DISTRIBUTE OR RE-SELL
THE MODIFIED VERSION IN ANY FORM.

THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/

// slot - competitor - points - played

if (!defined('CPG_NUKE')) { exit; }

$name_parts = explode('-',basename(__FILE__));
$thismod = $name_parts[1];
if (!is_active($thismod)) {
$content = 'ERROR';
return trigger_error($thismod.' is not Active!', E_USER_WARNING);
}

global $prefix, $user_prefix, $db;
$thispfx = $prefix.'_'.((strcmp($thismod,'Competition')==0)?'comp':strtolower($thismod));

$res = $db-&gt;sql_query('SELECT * FROM '.$thispfx.'config');
if (!$res) { return trigger_error('Configuration File Missing for '.$thismod, E_USER_WARNING); }
while ($row = $db->sql_fetchrow($res)) {
$mcomp[$row['cfg_field']] = $row['cfg_value'];
}
$db->sql_freeresult($res);

$content = '';

$inc = ' AND a.event=10';

$sql = '
SELECT
a.game, a.event, a.division, a.slot, a.cid, a.wins, a.draws, a.losses, a.points,
g.gname, g.gshort, g.gicon, e.ename, d.dname, t.tid, t.pid, t.tname, t.ttag, t.tcountry, u.username
FROM '.$thispfx.'division_team AS a
INNER JOIN '.$thispfx.'game AS g ON (g.game=a.game)
INNER JOIN '.$thispfx.'event AS e ON (e.event=a.event)
INNER JOIN '.$thispfx.'division AS d ON (d.division=a.division)
INNER JOIN '.$thispfx.'team AS t ON (t.cid=a.cid)
LEFT JOIN '.$user_prefix.'_users AS u ON (u.user_id=t.pid)
WHERE a.division > 0
AND e.pid = 0
AND (e.etype = 1
OR e.etype = 5)
AND e.estartdate &lt;= \''.date('Y-m-d H:i').'\'
AND e.eenddate &gt;= \''.date('Y-m-d H:i').'\'
'.$inc.'
ORDER BY a.game, a.event, a.division, a.slot';
$res = $db->sql_query($sql);
if ($db->sql_numrows($res)) {
$thisgame = 0; $thisevnt = 0; $thisdivn = 0; $newgame = false;
$content = '&lt;table width="100%" border="0" cellpadding="1" cellspacing="1"&gt;';
while ( list($game, $event, $division, $slot, $cid, $wins, $draws, $losses, $points, $gname, $gshort, $gicon, $ename, $dname, $tid, $pid, $tname, $ttag, $tcountry, $username) = $db->sql_fetchrow($res) ) {
if ($game != $thisgame || $event != $thisevnt) {
$gname = '&lt;a href="'.getlink($thismod.'&amp;game='.$game).'"&gt;&lt;img src="modules/'.$thismod.'/images/icons/'.$gicon.'" alt="'.$gname.'" title="'.$gname.'" border="0" /&gt; '.$gshort.'&lt;/a&gt;';
$ename = '&lt;a href="'.getlink($thismod.'&amp;event='.$event).'"&gt;'.$ename.'&lt;/a&gt;';
if ($newgame) {
$content .= '&lt;tr&gt;&lt;td colspan="4"&gt;&lt;hr noshade size=1 /&gt;&lt;/td&gt;&lt;/tr&gt;';
}
$content .= '&lt;tr&gt;&lt;td align="left" colspan="4"&gt;'.$gname.' '.$ename.'&lt;/td&gt;&lt;/tr&gt;';
$thisgame = $game; $thisevnt = $event; $newgame = true;
}
if ($division != $thisdivn) {
$content .= '
&lt;tr&gt;
&lt;td align="left" colspan="2"&gt;<b>'.$dname.'</b>&lt;/td&gt;
&lt;td align="center"&gt;<b>Pts</b>&lt;/td&gt;
&lt;td align="center"&gt;<b>Pld</b>&lt;/td&gt;
&lt;/tr&gt;
';
$thisdivn = $division;
}
$tname = ($tid!=0 && $pid==0) ? (($ttag=='')?$tname:$ttag) : $username ;
$tlink = ($tid!=0 && $pid==0) ? getlink($thismod.'&file=teams&op=teamProfile&cid='.$cid) : getlink($thismod.'&file=players&op=playerProfile&cid='.$cid) ;
$tname = '&lt;a href="'.$tlink.'"&gt;'.$tname.'&lt;/a&gt;';
$tname = '&lt;img src="images/flags/'.$tcountry.$mcomp['flag_ext'].'" border="0"&gt;&nbsp;'.$tname;
$content .= '
&lt;tr&gt;
&lt;td align="left"&gt;'.$slot.'&lt;/td&gt;
&lt;td align="left"&gt;'.$tname.'&lt;/td&gt;
&lt;td align="center"&gt;'.$points.'&lt;/td&gt;
&lt;td align="center"&gt;'.($wins + $draws + $losses).'&lt;/td&gt;
&lt;/tr&gt;
';
}
$content .= '&lt;/table&gt;';
}
$db->sql_freeresult($res);

?>

mikesu
Newbie
Newbie
 

making it so blocks can display different events

Post Posted: Thu Sep 25, 2008 8:09 am

I've had a look through the block display code in DragonFly, and the text There appears to be a problem with this block is output if it can't find the block file in the first place. I doubt there's anything wrong with the code, it just can't find the file. Make sure the file actually exists in the blocks folder.

mark
Site Admin
Site Admin
 

making it so blocks can display different events

Post Posted: Thu Sep 25, 2008 5:31 pm

yeah its deffinatley there, i select the block from FILE. and i check on FTP and its there in the blocks folder.

Think it just doesnt like me lol

Mike

mikesu
Newbie
Newbie
 

making it so blocks can display different events

Post Posted: Thu Sep 25, 2008 7:32 pm

DragonFly is not doing anything special here, it uses the PHP file_exists() function to check the file is there. This function can return false if the server is running PHP in safe mode, which is sometimes the case on shared hosting accounts.

If you go to your Admin panel, select "System Info" and then "PHP core" it'll tell you somewhere down there what the value of safe mode is.

mark
Site Admin
Site Admin
 

making it so blocks can display different events

Post Posted: Sat Sep 27, 2008 3:22 pm

PHP Core

Directive Local Value Master Value

safe_mode Off Off
safe_mode_exec_dir no value no value
safe_mode_gid Off Off
safe_mode_include_dir no value no value

mikesu
Newbie
Newbie
 

making it so blocks can display different events

Post Posted: Sun Sep 28, 2008 8:57 am

OK, safe mode is not on. The only other thing I can find that might have a bearing is file permissions, the file exists but the web server doesn't have permission to read it so can't see it.

Assuming you have an FTP program that can change permissions, or have direct access to the server, check the file permissions. If it's a Unix / Linux server make sure the file is readable by anyone (CHMOD 644).

mark
Site Admin
Site Admin
 
Page 1 of 2
Go to page 1, 2  Next



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum